--- JspServlet.java.orig 2005-04-01 22:10:50.375000000 -0800 +++ JspServlet.java 2005-04-01 22:12:50.390625000 -0800 @@ -17,6 +17,7 @@ package org.apache.jasper.servlet; import java.io.IOException; +import java.lang.reflect.Constructor; import java.util.Enumeration; import javax.servlet.ServletConfig; @@ -67,19 +68,42 @@ */ public void init(ServletConfig config) throws ServletException { - super.init(config); - this.config = config; - this.context = config.getServletContext(); + super.init(config); + this.config = config; + this.context = config.getServletContext(); + + // Check for a custom Options implementation + String engineOptionsName = + config.getInitParameter("engineOptionsClass"); + if (engineOptionsName != null) { + // Instantiate the indicated Options implementation + try { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + Class engineOptionsClass = loader.loadClass(engineOptionsName); + Class[] ctorSig = {ServletConfig.class, ServletContext.class}; + Constructor ctor = engineOptionsClass.getConstructor(ctorSig); + Object[] args = {config, context}; + options = (Options) ctor.newInstance(args); + } catch(Throwable e) { + // Need to localize this. + log.warn("Failed to load engineOptionsClass", e); + // Use the default Options implementation + options = new EmbeddedServletOptions(config, context); + } + } + else { + // Use the default Options implementation + options = new EmbeddedServletOptions(config, context); + } // Initialize the JSP Runtime Context - options = new EmbeddedServletOptions(config, context); rctxt = new JspRuntimeContext(context,options); - if (log.isDebugEnabled()) { - log.debug(Localizer.getMessage("jsp.message.scratch.dir.is", - options.getScratchDir().toString())); - log.debug(Localizer.getMessage("jsp.message.dont.modify.servlets")); - } + if (log.isDebugEnabled()) { + log.debug(Localizer.getMessage("jsp.message.scratch.dir.is", + options.getScratchDir().toString())); + log.debug(Localizer.getMessage("jsp.message.dont.modify.servlets")); + } } @@ -164,11 +188,11 @@ if (value.equals("true")) { return (true); // ?jsp_precompile=true } else if (value.equals("false")) { - // Spec says if jsp_precompile=false, the request should not - // be delivered to the JSP page; the easiest way to implement - // this is to set the flag to true, and precompile the page anyway. - // This still conforms to the spec, since it says the - // precompilation request can be ignored. + // Spec says if jsp_precompile=false, the request should not + // be delivered to the JSP page; the easiest way to implement + // this is to set the flag to true, and precompile the page anyway. + // This still conforms to the spec, since it says the + // precompilation request can be ignored. return (true); // ?jsp_precompile=false } else { throw new ServletException("Cannot have request parameter " + @@ -180,7 +204,7 @@ public void service (HttpServletRequest request, - HttpServletResponse response) + HttpServletResponse response) throws ServletException, IOException { String jspUri = null; @@ -197,7 +221,7 @@ jspUri = (String) request.getAttribute(Constants.INC_SERVLET_PATH); if (jspUri != null) { /* - * Requested JSP has been target of + * Requested JSP has been target of * RequestDispatcher.include(). Its path is assembled from the * relevant javax.servlet.include.* request attributes */ @@ -220,7 +244,7 @@ } } - if (log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("JspEngine --> " + jspUri); log.debug("\t ServletPath: " + request.getServletPath()); log.debug("\t PathInfo: " + request.getPathInfo()); @@ -293,4 +317,3 @@ } } -