summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/WeblogServlet.java
diff options
context:
space:
mode:
Diffstat (limited to 'org/madore/damlengine/WeblogServlet.java')
-rw-r--r--org/madore/damlengine/WeblogServlet.java42
1 files changed, 37 insertions, 5 deletions
diff --git a/org/madore/damlengine/WeblogServlet.java b/org/madore/damlengine/WeblogServlet.java
index 181c782..6b9b738 100644
--- a/org/madore/damlengine/WeblogServlet.java
+++ b/org/madore/damlengine/WeblogServlet.java
@@ -1,27 +1,58 @@
package org.madore.damlengine;
+import java.util.Properties;
+import java.util.Enumeration;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.ResourceBundle;
-import java.util.Date;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
+import java.nio.file.Paths;
+import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+/* Thinkos about the mess that is tomcat:
+
+ * - Make sure that /usr/share/java/postgresql-jdbc3.jar (or whatever
+ * contains the class org.postgresql.Driver) is symlinked from
+ * /var/lib/tomcat7/common (or some path listed in the common.loader
+ * property of the catalina.properties file). Similarly,
+ * xercesImpl.jar and probably xml-resolver.jar need to be linked.
+
+ * - The following parameters need to be defined in <init-param> tags
+ * inside the <servlet> block: base_path, template_path, pghost,
+ * pgport, dbname, pguser and pgpass or pgpassfile.
+
+ */
+
public class WeblogServlet extends HttpServlet {
- private static final long serialVersionUID = 2014100301L;
+ private static final long serialVersionUID = 2014100406L;
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
+
DamlEngine.runAsServlet = true;
+ DamlEngine.appProps = new Properties();
+ ServletConfig cfg = getServletConfig();
+ for (Enumeration<String> e = cfg.getInitParameterNames() ; e.hasMoreElements() ; ) {
+ String k = e.nextElement();
+ DamlEngine.appProps.setProperty(k, cfg.getInitParameter(k));
+ }
+
+ if ( DamlEngine.appProps.getProperty("base_path") != null )
+ DamlEngine.basePath = Paths.get(DamlEngine.appProps.getProperty("base_path"));
+ if ( DamlEngine.basePath == null )
+ DamlEngine.basePath = Paths.get(getServletContext().getRealPath("/"));
+ if ( DamlEngine.appProps.getProperty("template_path") != null )
+ DamlEngine.templatePath = Paths.get(DamlEngine.appProps.getProperty("template_path"));
+ if ( DamlEngine.templatePath == null )
+ DamlEngine.templatePath = DamlEngine.basePath.resolve("templates");
+
response.setContentType("text/html; charset=utf-8");
response.setCharacterEncoding("UTF-8");
OutputStream out = response.getOutputStream();
@@ -32,5 +63,6 @@ public class WeblogServlet extends HttpServlet {
} catch (Exception e) {
throw new ServletException("exception during WeblogSelect.fullProcess()", e);
}
+
}
}