use req.getContextPath to find the RootUri.. much more robust. 4.0 and 4.1 compatible...
authormh <mh>
Mon, 25 Nov 2002 21:59:46 +0000 (21:59 +0000)
committermh <mh>
Mon, 25 Nov 2002 21:59:46 +0000 (21:59 +0000)
etc/web.xml
source/Mir.java
source/OpenMir.java
source/mir/misc/HTMLTemplateProcessor.java
source/mir/misc/MirConfig.java
source/mir/servlet/AbstractServlet.java
source/mircoders/producer/Producer.java

index 7169c05..c1b1d00 100755 (executable)
 
     </servlet>
     
-    <servlet>
+    <servlet-mapping>
         <servlet-name>
-            OutputMir
+            Mir
         </servlet-name>
-        <servlet-class>
-            OutputMir
-        </servlet-class>
-
-        <init-param>
-            <param-name>Config</param-name>
-            <param-value>config</param-value>
-        </init-param>
-
-    </servlet>
+        <url-pattern>
+            /Mir
+        </url-pattern>
+    </servlet-mapping>
 
     <servlet-mapping>
         <servlet-name>
             Mir
         </servlet-name>
         <url-pattern>
-            /Mir
+            /servlet/Mir
         </url-pattern>
     </servlet-mapping>
 
@@ -65,8 +59,8 @@
     </servlet-mapping>
 
     <servlet-mapping>
-        <servlet-name>OutputMir</servlet-name>
-        <url-pattern>/OutputMir</url-pattern>
+        <servlet-name>OpenMir</servlet-name>
+        <url-pattern>/servlet/OpenMir</url-pattern>
     </servlet-mapping>
 
     <mime-mapping>
index f66b9a7..545d85f 100755 (executable)
@@ -58,9 +58,12 @@ import java.util.Locale;
  * Mir.java - main servlet, that dispatches to servletmodules
  *
  * @author $Author: mh $
- * @version $Revision: 1.17.2.1 $ $Date: 2002/09/01 21:31:39 $
+ * @version $Revision: 1.17.2.2 $ $Date: 2002/11/25 21:59:47 $
  *
  * $Log: Mir.java,v $
+ * Revision 1.17.2.2  2002/11/25 21:59:47  mh
+ * use req.getContextPath to find the RootUri.. much more robust. 4.0 and 4.1 compatible due to new web.xml mapping
+ *
  * Revision 1.17.2.1  2002/09/01 21:31:39  mh
  * Mir goes GPL
  *
@@ -76,6 +79,8 @@ public class Mir extends AbstractServlet {
     private static ModuleMessage messageModule = null;
     private final static HashMap servletModuleInstanceHash = new HashMap();
 
+    private static boolean nameSet = false;
+
     public HttpSession session;
 
     public void doGet(HttpServletRequest req, HttpServletResponse res)
@@ -95,7 +100,11 @@ public class Mir extends AbstractServlet {
         if (getServletContext().getAttribute("mir.confed") == null) {
             getConfig(req);
         }
-        MirConfig.setServletName(getServletName());
+
+        if (!nameSet) {
+          MirConfig.setAdminServletName(getServletName());
+          nameSet = true;
+        }
 
         session = req.getSession(true);
 
index da49b75..912a666 100755 (executable)
@@ -61,6 +61,8 @@ public class OpenMir extends AbstractServlet {
   private static String lang;
   public HttpSession session;
 
+  private boolean nameSet = false;
+
   public void doGet(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
     doPost(req,res);
@@ -77,6 +79,11 @@ public class OpenMir extends AbstractServlet {
     if(getServletContext().getAttribute("mir.confed") == null) {
       getConfig(req);
     }
+    if (!nameSet) {
+        MirConfig.setOpenServletName(getServletName());
+        nameSet = true;
+    }
+      
     session = req.getSession();
 
     if(session.getAttribute("Language")==null){
index 63f088e..f517a3c 100755 (executable)
@@ -87,7 +87,7 @@ public final class HTMLTemplateProcessor {
          //actionRoot = docRoot + "/servlet/" + MirConfig.getProp("ServletName");
     //actionRoot = docRoot + "/servlet/NadirAktuell";
 
-    actionRoot = docRoot + "/servlet/Mir";
+    actionRoot = docRoot + "/Mir";
 
     defEncoding = MirConfig.getProp("Mir.DefaultEncoding");
     openAction = MirConfig.getProp("Producer.OpenAction");
index c628d48..b188752 100755 (executable)
@@ -74,14 +74,14 @@ public class MirConfig extends Configuration {
    * @param name, The name of the servlet (usually "Mir")
    * @param confName, the name of the config file to load.
    */
-  public static synchronized void initConfig(ServletContext ctx, String uri,
+  public static synchronized void initConfig(ServletContext ctx, String ctxPath,
                                             String name, String confName) {
     initConfResource(confName);
     configHash = new HashMap();
 
     configHash.put("Home", ctx.getRealPath("/"));
     configHash.put("ServletContext", ctx);
-    configHash.put("RootUri", uri);
+    configHash.put("RootUri", ctxPath);
 
     Enumeration resKeys = getResourceKeys();
     while(resKeys.hasMoreElements()) {
@@ -89,13 +89,13 @@ public class MirConfig extends Configuration {
       configHash.put(keyNm, getProperty(keyNm));
     }
   }
-  /**
-   * Returns the property asked for by pulling it out a HashMap
-   * @param a String containing the property name (key)
-   * @return a String containing the prop. value
-   */
-  public static void setServletName(String servletName) {
-    configHash.put("ServletName",servletName);
+
+  public static void setAdminServletName(String servletName) {
+    configHash.put("AdminServletName",servletName);
+  }
+
+  public static void setOpenServletName(String servletName) {
+    configHash.put("OpenServletName",servletName);
   }
 
   /**
index 715c830..ef36bf2 100755 (executable)
@@ -46,10 +46,10 @@ import java.util.Random;
 /**
  * Title:        Mir
  * Description:  Abstract servlet-class
- * Copyright:    Copyright (c) 2001
- * Company:      Indymedia
- * @author       idfx
- * @version 1.0
+ * Copyright:    Copyright (c) 2001, 2002
+ * Company:      Mir-coders group
+ * @author       idfx, the Mir-coders group
+ * @version      $Id: AbstractServlet.java,v 1.15.4.4 2002/11/25 21:59:46 mh Exp $
  */
 
 public abstract class AbstractServlet extends HttpServlet {
@@ -63,14 +63,12 @@ public abstract class AbstractServlet extends HttpServlet {
             throws UnavailableException {
 
         //String RealPath = super.getServletContext().getRealPath("/");
-        String uri = req.getRequestURI();
         String name = super.getServletName();
-        String rootUri = StringUtil.replace(uri, "/servlet/"+name, "");
 
         // init config
         //MirConfig.initConfig(RealPath, RootUri, Name, getInitParameter("Config"));
-        MirConfig.initConfig(super.getServletContext(), rootUri, name,
-                              getInitParameter("Config"));
+        MirConfig.initConfig(super.getServletContext(), req.getContextPath(),
+                              name, getInitParameter("Config"));
 
         theLog = Logfile.getInstance(MirConfig.getPropWithHome(name + ".Logfile"));
         theLog.printInfo(name + " started.");
index c62d9ca..94e08e5 100755 (executable)
@@ -50,7 +50,6 @@ abstract public class Producer {
   protected static String   producerProductionHost = MirConfig.getProp("Producer.ProductionHost");
   protected static String   producerOpenAction = MirConfig.getProp("Producer.OpenAction");;
 
-  /** @todo same as in HTMLTemplateProcessor, this should be dynamically set */
   protected static String   actionRoot = MirConfig.getProp("RootUri") + "/Mir";
 
   protected static Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home") + "/" + MirConfig.getProp("Producer.Logfile"));