@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try {
String id = req.getParameter("id");
Advertising obj = AdvertisingModel.byId(id, false);
HttpSession session = req.getSession();
if (obj != null) {
int type = 0;
int place = 0;
int position = 0;
String strType = req.getParameter("advertisingType");
String strPlace = req.getParameter("place");
String strPosition = req.getParameter("position");
try {
type = Integer.parseInt(strType);
} catch (Exception e) {
type = 0;
}
try {
place = Integer.parseInt(strPlace);
} catch (Exception e) {
place = 0;
}
try {
position = Integer.parseInt(strPosition);
} catch (Exception e) {
position = 0;
}
if (type == 1 && place != 0 && position != 0) {
String content = req.getParameter("content");
obj.setType(type);
obj.setPlace(place);
obj.setPosition(position);
obj.setContent(content);
AdvertisingModel.insert(obj);
session.setAttribute("success", "Action success !");
resp.sendRedirect("/admin/advertising/manage?place="
+ place);
} else if (type == 2 && place != 0 && position != 0) {
String title = (String) req.getParameter("title");
String link = (String) req.getParameter("link");
String imgKey = BlobKeyProcess.getBlobKey(req, "image");
obj.setType(type);
obj.setPlace(place);
obj.setPosition(position);
obj.setTitle(title);
obj.setLink(link);
obj.setContent(imgKey);
AdvertisingModel.insert(obj);
session.setAttribute("success", "Action success !");
resp.sendRedirect("/admin/advertising/manage?place="
+ place);
} else {