import javax.servlet.http.HttpSession;
import java.io.File;
import java.util.Locale;
+import java.util.HashMap;
import mir.misc.HTMLTemplateProcessor;
-import mir.misc.Configuration;
+import mir.misc.StringUtil;
+import mir.misc.MirConfig;
import mir.misc.Logfile;
/**
protected static Logfile theLog;
/**
- * get the configration
+ * the configration
*/
protected boolean getConfig(HttpServletRequest req) {
- Configuration.initConfig(getInitParameter("Config"));
- theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("Mir.Logfile"));
- theLog.printInfo(super.getServletName() + " started.");
+
+ 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"));
+
+ theLog = Logfile.getInstance(this.getClass().getName());
+ theLog.printInfo(Name + " started.");
+ theLog.printInfo("Path is: " + MirConfig.getProp("Home"));
+ theLog.printInfo("Root URI is: " + MirConfig.getProp("RootUri"));
+ theLog.printInfo("Lang is: " + MirConfig.getProp("StandardLanguage"));
return true;
}
}
/**
- * Get the session-binded language
+ * Get the session-bound language
*/
protected String getLanguage(HttpServletRequest req, HttpSession session){
String lang = (String)session.getAttribute("Language");
- if(lang==null || lang==""){
+ if(lang==null || lang.equals("")){
return getAcceptLanguage(req);
} else {
return lang;
}
/**
- * Checks the Accept-Language of the clients browser.
- * if this language is available it returns its country-code,
+ * Checks the Accept-Language of the client browser.
+ * If this language is available it returns its country-code,
* else it returns the standard-language
*/
protected String getAcceptLanguage(HttpServletRequest req){
//is there an existing template-path?
if(!f.isDirectory()){
//no there isn't. we use standard-language
- lang = Configuration.getProperty("StandardLanguage");
+ lang = MirConfig.getProp("StandardLanguage");
theLog.printDebugInfo("language not existing");
}
theLog.printDebugInfo("Language: " + lang);