From 2b09cdd9abce74d1a3e51ed1d02447c8ca243851 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 7 Oct 2014 14:02:40 +0200 Subject: Move servlet initialization in the .init() method. --- org/madore/damlengine/WeblogServlet.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'org/madore') diff --git a/org/madore/damlengine/WeblogServlet.java b/org/madore/damlengine/WeblogServlet.java index 9cf1a75..4baf055 100644 --- a/org/madore/damlengine/WeblogServlet.java +++ b/org/madore/damlengine/WeblogServlet.java @@ -28,18 +28,16 @@ import javax.servlet.http.HttpServletResponse; public class WeblogServlet extends HttpServlet { - private static final long serialVersionUID = 2014100407L; + private static final long serialVersionUID = 2014100701L; @Override - public void doGet(HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException + public void init(ServletConfig cfg) + throws ServletException { - + super.init(cfg); // Important! synchronized ( DamlEngine.class ) { if ( DamlEngine.appProps == null ) { DamlEngine.runAsServlet = true; DamlEngine.appProps = new Properties(); - ServletConfig cfg = getServletConfig(); for (Enumeration e = cfg.getInitParameterNames() ; e.hasMoreElements() ; ) { String k = e.nextElement(); DamlEngine.appProps.setProperty(k, cfg.getInitParameter(k)); @@ -53,7 +51,13 @@ public class WeblogServlet extends HttpServlet { if ( DamlEngine.templatePath == null ) DamlEngine.templatePath = DamlEngine.basePath.resolve("templates"); } } + } + @Override + public void doGet(HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException + { response.setContentType("text/html; charset=utf-8"); response.setCharacterEncoding("UTF-8"); OutputStream out = response.getOutputStream(); -- cgit v1.2.3