From: mh Date: Tue, 26 Nov 2002 00:25:59 +0000 (+0000) Subject: use req.getContextPath to find the RootUri.. much more robust. 4.0 and 4.1 compatible... X-Git-Tag: BEFORE_MERGE_1_1~464 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=6bbdfc182efde72c25fa29e57afc23d3fc5def32;p=mir.git use req.getContextPath to find the RootUri.. much more robust. 4.0 and 4.1 compatible due to new web.xml mapping --- diff --git a/etc/web.xml b/etc/web.xml index d47a97e5..42b57983 100755 --- a/etc/web.xml +++ b/etc/web.xml @@ -35,27 +35,21 @@ - + - OutputMir + Mir - - OutputMir - - - - Config - config - - - + + /Mir + + Mir - /Mir + /servlet/Mir @@ -63,10 +57,9 @@ OpenMir /OpenMir - - OutputMir - /OutputMir + OpenMir + /servlet/OpenMir diff --git a/source/mir/misc/HTMLTemplateProcessor.java b/source/mir/misc/HTMLTemplateProcessor.java index 3f014cc3..b86fd25f 100755 --- a/source/mir/misc/HTMLTemplateProcessor.java +++ b/source/mir/misc/HTMLTemplateProcessor.java @@ -68,7 +68,7 @@ public final class HTMLTemplateProcessor { actionRoot = docRoot + MirConfig.getProp("Producer.ActionServlet"); } catch (ConfigException ce) { // if Producer.ActionServlet is not set in the conf file - actionRoot = docRoot + "/servlet/Mir"; + actionRoot = docRoot + "/Mir"; } } diff --git a/source/mir/misc/MirConfig.java b/source/mir/misc/MirConfig.java index b84c21b7..ebcd9658 100755 --- a/source/mir/misc/MirConfig.java +++ b/source/mir/misc/MirConfig.java @@ -74,7 +74,7 @@ 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(ctx.getRealPath("/WEB-INF/")+"/"+confName); @@ -83,7 +83,7 @@ public class MirConfig extends Configuration { configHash.put("Home", ctx.getRealPath("/WEB-INF/")+"/"); configHash.put("ServletContext", ctx); - configHash.put("RootUri", uri); + configHash.put("RootUri", ctxPath); Enumeration resKeys = getResourceKeys(); while(resKeys.hasMoreElements()) { diff --git a/source/mir/servlet/AbstractServlet.java b/source/mir/servlet/AbstractServlet.java index 70ddc614..b9a99e5f 100755 --- a/source/mir/servlet/AbstractServlet.java +++ b/source/mir/servlet/AbstractServlet.java @@ -63,17 +63,15 @@ 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, ""); + String name = super.getServletName(); // 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."); + theLog = Logfile.getInstance(MirConfig.getPropWithHome(name + ".Logfile")); + theLog.printInfo(name + " started."); theLog.printInfo("Path is: " + MirConfig.getProp("Home")); theLog.printInfo("Root URI is: " + MirConfig.getProp("RootUri")); theLog.printInfo("StandardLanguage is: " + MirConfig.getProp("StandardLanguage")); diff --git a/source/mircoders/producer/Producer.java b/source/mircoders/producer/Producer.java index c2cb9771..94e08e53 100755 --- a/source/mircoders/producer/Producer.java +++ b/source/mircoders/producer/Producer.java @@ -50,8 +50,7 @@ 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") + "/servlet/Mir"; + protected static String actionRoot = MirConfig.getProp("RootUri") + "/Mir"; protected static Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home") + "/" + MirConfig.getProp("Producer.Logfile")); protected static ModuleTopics topicsModule;