add no-cache Pragma and Cache-control headers to the http response.. I see no reason...
[mir.git] / source / Mir.java
index ea6ddaa..afb3351 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, 2002  The Mir-coders group
+ * Copyright (C) 2001, 2002 The Mir-coders group
  *
  * This file is part of Mir.
  *
@@ -66,21 +66,8 @@ import mir.log.Log;
 /**
  * Mir.java - main servlet, that dispatches to servletmodules
  *
- * @author $Author: bruno $
- * @version $Revision: 1.20 $ $Date: 2002/10/09 16:09:05 $
- *
- * $Log: Mir.java,v $
- * Revision 1.20  2002/10/09 16:09:05  bruno
- * contains only admin templates which should not be changed by users
- *
- * Revision 1.19  2002/09/01 22:05:47  mh
- * Mir goes GPL
- *
- * Revision 1.18  2002/08/25 19:00:06  mh
- * merge of localization branch into HEAD. mh and zap
- *
- * Revision 1.17  2002/07/21 22:27:39  mh
- * make the user error msg look nicer
+ * @author $Author: mh $
+ * @version $Id: Mir.java,v 1.23 2002/12/06 08:12:42 mh Exp $
  *
  */
 
@@ -108,11 +95,10 @@ public class Mir extends AbstractServlet {
         EntityUsers userEntity;
         String http = "";
 
-        // get the configration - this could conflict if 2 mirs are in the
-        // VM maybe? to be checked. -mh
         if (getServletContext().getAttribute("mir.confed") == null) {
             getConfig(req);
         }
+
         MirConfig.setServletName(getServletName());
 
         //*** test
@@ -122,6 +108,14 @@ public class Mir extends AbstractServlet {
         userEntity = (EntityUsers) session.getAttribute("login.uid");
 
         if (req.getServerPort() == 443) http = "https"; else http = "http";
+
+        //nothing in Mir can or should be cached as it's all dynamic...
+        //
+        //this needs to be done here and not per page (via meta tags) as some
+        //browsers have problems w/ it per-page -mh
+        res.setHeader("Pragma", "no-cache");
+        res.setDateHeader("Expires", 0);
+        res.setHeader("Cache-Control", "no-cache");
         res.setContentType("text/html; charset="
                             +MirConfig.getProp("Mir.DefaultEncoding"));
         String moduleName = req.getParameter("module");
@@ -229,10 +223,10 @@ public class Mir extends AbstractServlet {
         }
         catch (ServletModuleException e) {
             handleError(req, res, res.getWriter(),
-                        "ServletException in Module " + moduleName + " -- " + e.toString());
+                        "ServletException in Module " + moduleName + " -- " + e.getMessage());
         }
         catch (ServletModuleUserException e) {
-            handleUserError(req, res, res.getWriter(), e.getMsg());
+            handleUserError(req, res, res.getWriter(), e.getMessage());
         }
 
         // timing...
@@ -272,7 +266,7 @@ public class Mir extends AbstractServlet {
             }
             catch (Exception e) {
                 throw new ServletModuleException("*** error resolving classname for " +
-                                                 moduleName + " -- " + e.toString());
+                                                 moduleName + " -- " + e.getMessage());
             }
         }
         else
@@ -292,7 +286,8 @@ public class Mir extends AbstractServlet {
             out.close();
         }
         catch (Exception e) {
-            System.err.println("Error in ErrorTemplate");
+          e.printStackTrace(System.out);
+          System.err.println("Error in ErrorTemplate: " + e.getMessage());
         }
     }
 
@@ -308,7 +303,7 @@ public class Mir extends AbstractServlet {
             out.close();
         }
         catch (Exception e) {
-            System.err.println("Fehler in UserErrorTemplate");
+            System.err.println("Error in UserErrorTemplate");
         }
 
     }
@@ -322,7 +317,7 @@ public class Mir extends AbstractServlet {
             return usersModule.getUserForLogin(user, password);
         }
         catch (Exception e) {
-            theLog.printDebugInfo(e.toString());
+            theLog.printDebugInfo(e.getMessage());
             e.printStackTrace();
             return null;
         }
@@ -361,6 +356,7 @@ public class Mir extends AbstractServlet {
 
             mergeData.put("articletypes", DatabaseArticleType.getInstance().selectByWhereClause("", "id", 0, 20));
 
+/*
             SimpleList producersData = new SimpleList();
             Iterator i = MirGlobal.localizer().producers().factories().entrySet().iterator();
             while (i.hasNext()) {
@@ -379,14 +375,14 @@ public class Mir extends AbstractServlet {
               producersData.add(producerData);
             }
             mergeData.put("producers", producersData);
-
+ */
 
 
             HTMLTemplateProcessor.process(res, startTemplate, mergeData, out, getLocale(req));
         }
         catch (Exception e) {
             e.printStackTrace(System.out);
-            handleError(req, res, out, "error while trying to send startpage. " + e.toString());
+            handleError(req, res, out, "error while trying to send startpage. " + e.getMessage());
         }
     }