From 4c2f3f483afb8835e0845046d575adc087dd17e4 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Fri, 3 Oct 2014 23:30:29 +0200 Subject: Start writing a servlet version. NOT USABLE YET. --- org/madore/damlengine/DamlEngine.java | 1 + org/madore/damlengine/WeblogServlet.java | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 org/madore/damlengine/WeblogServlet.java diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java index a0299ad..9ac0c08 100644 --- a/org/madore/damlengine/DamlEngine.java +++ b/org/madore/damlengine/DamlEngine.java @@ -153,6 +153,7 @@ public final class DamlEngine { fullProcess(in, out, null); } + public static boolean runAsServlet = false; public static Properties appProps; public static Path basePath; public static Path templatePath; diff --git a/org/madore/damlengine/WeblogServlet.java b/org/madore/damlengine/WeblogServlet.java new file mode 100644 index 0000000..181c782 --- /dev/null +++ b/org/madore/damlengine/WeblogServlet.java @@ -0,0 +1,36 @@ +package org.madore.damlengine; + +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 javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class WeblogServlet extends HttpServlet { + + private static final long serialVersionUID = 2014100301L; + + @Override + public void doGet(HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException + { + DamlEngine.runAsServlet = true; + response.setContentType("text/html; charset=utf-8"); + response.setCharacterEncoding("UTF-8"); + OutputStream out = response.getOutputStream(); + final int number = 1729; + try { + WeblogSelect.fullProcess(new Context.WeblogSingleSelectionContext(number), + out); + } catch (Exception e) { + throw new ServletException("exception during WeblogSelect.fullProcess()", e); + } + } +} -- cgit v1.2.3