direct op
[mir.git] / source / OpenMir.java
index 9219855..4b1d178 100755 (executable)
@@ -24,59 +24,64 @@ import mircoders.storage.*;
  */
 
 
-public class OpenMir extends AbstractServlet
-{
-       private static Logfile                theLog;
-       private static boolean                confed=false;
-       private static String   lang;
+public class OpenMir extends AbstractServlet {
+  
+  private static boolean                confed=false;
+  private static String lang;
+  public HttpSession session;
 
-       public void doGet(HttpServletRequest req, HttpServletResponse res)
-               throws ServletException, IOException {
-               doPost(req,res);
-       }
+  public void doGet(HttpServletRequest req, HttpServletResponse res)
+    throws ServletException, IOException {
+    doPost(req,res);
+  }
 
-       public void doPost(HttpServletRequest req, HttpServletResponse res)
-               throws ServletException, IOException {
+  public void doPost(HttpServletRequest req, HttpServletResponse res)
+    throws ServletException, IOException {
 
-               long            startTime = (new java.util.Date()).getTime();
-               long            sessionConnectTime=0;
+    long            startTime = (new java.util.Date()).getTime();
+    long            sessionConnectTime=0;
 
+    
     if (!confed){
       confed = getConfig(req);
     }
+    
+    session = req.getSession();
 
-               HttpSession session = req.getSession(true);
     if(session.getAttribute("Language")==null){
-      setLanguage(req,getAcceptLanguage(req));
+      setLanguage(session,getAcceptLanguage(req));
     }
 
-               res.setContentType("text/html");
-               try {
-                       ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res);
-               }
-               catch (ServletModuleException e){ handleError(res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); }
-               // timing...
-               sessionConnectTime = new java.util.Date().getTime() - startTime;
-               theLog.printInfo("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms");
-       }
-
-       private void handleError(PrintWriter out, String errorString) {
-
-               try {
-                       theLog.printError(errorString);
-                       SimpleHash modelRoot = new SimpleHash();
-                       modelRoot.put("errorstring", new SimpleScalar(errorString));
-                       modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
-                       HTMLTemplateProcessor.process(Configuration.getProperty("Mir.ErrorTemplate"),modelRoot,out);
-                       out.close();
-               }
-               catch (Exception e) {
-                       System.err.println("Fehler in ErrorTemplate");
-               }
-
-       }
-
-       public String getServletInfo(){ return "OpenIndy 1.0 rev01"; }
+    res.setContentType("text/html");
+    try {
+      ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res);
+    }
+    catch (ServletModuleException e){
+      e.printStackTrace();
+      handleError(res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString());
+    }
+    // timing...
+    sessionConnectTime = new java.util.Date().getTime() - startTime;
+    theLog.printInfo("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms");
+  }
+
+  private void handleError(HttpServletResponse res,PrintWriter out, String errorString) {
+
+    try {
+      theLog.printError(errorString);
+      SimpleHash modelRoot = new SimpleHash();
+      modelRoot.put("errorstring", new SimpleScalar(errorString));
+      modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
+      HTMLTemplateProcessor.process(res,Configuration.getProperty("Mir.ErrorTemplate"),modelRoot,out);
+      out.close();
+    }
+    catch (Exception e) {
+      System.err.println("Fehler in ErrorTemplate");
+    }
+
+  }
+
+  public String getServletInfo(){ return "OpenIndy 1.0 rev01"; }
 
 }