2018-07-23 16:55:28 +02:00
|
|
|
package zall;
|
|
|
|
|
|
|
|
|
|
import zutil.db.DBConnection;
|
|
|
|
|
import zutil.log.LogUtil;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.RequestDispatcher;
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.sql.SQLException;
|
2018-07-24 16:23:53 +02:00
|
|
|
import java.util.PropertyResourceBundle;
|
|
|
|
|
import java.util.ResourceBundle;
|
2018-07-23 16:55:28 +02:00
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
2018-07-26 16:23:01 +02:00
|
|
|
import static zall.ZalleryConstant.*;
|
2018-07-24 16:23:53 +02:00
|
|
|
|
2018-07-23 16:55:28 +02:00
|
|
|
public abstract class ZalleryServlet extends HttpServlet {
|
|
|
|
|
private static Logger logger = LogUtil.getLogger();
|
2018-07-26 16:23:01 +02:00
|
|
|
protected ResourceBundle lang = PropertyResourceBundle.getBundle(LANG_BASENAME, LANG_DEFAULT);
|
2018-07-23 16:55:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
public final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
|
|
|
|
DBConnection db = null;
|
|
|
|
|
try {
|
|
|
|
|
doGet(request, response, db = Zallery.getDB());
|
|
|
|
|
} catch (ServletException e) {
|
|
|
|
|
throw e;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServletException(e);
|
|
|
|
|
} finally {
|
|
|
|
|
if (db != null) db.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, SQLException, IOException {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public final void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
|
|
|
|
DBConnection db = null;
|
|
|
|
|
try {
|
|
|
|
|
doPost(request, response, db = Zallery.getDB());
|
|
|
|
|
} catch (ServletException e) {
|
|
|
|
|
throw e;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServletException(e);
|
|
|
|
|
} finally {
|
|
|
|
|
if (db != null) db.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void doPost(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, SQLException, IOException {
|
|
|
|
|
doGet(request, response, db);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void include(String url, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
|
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + url);
|
|
|
|
|
if (dispatcher != null)
|
|
|
|
|
dispatcher.include(request, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void forward(String url, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
|
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + url);
|
|
|
|
|
if (dispatcher != null)
|
|
|
|
|
dispatcher.forward(request, response);
|
|
|
|
|
}
|
|
|
|
|
}
|