public void handleMissingResource( HttpServletRequest request, HttpServletResponse response, String jspUri) throws ServletException, IOException, RemoteException { try { String includeRequestUri = (String) request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI); if (includeRequestUri != null) { // This file was included. Throw an exception as // a response.sendError() will be ignored String msg = gerenciadornuvem0.LocalizergetMessage("jsp.error.file.not.found", jspUri); // Strictly, filtering this is an application // responsibility but just in case... throw new ServletException(gerenciadornuvem1.SecurityUtil2filter(msg)); } else { try { response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI()); } catch (IllegalStateException ise) { log.error(gerenciadornuvem0.LocalizergetMessage("jsp.error.file.not.found", jspUri)); } } return; } catch (Exception excp) { excp.printStackTrace(); } }
/* * Initializes this JspServlet. */ @Override public void init(ServletConfig config) throws ServletException, RemoteException { try { super.init(config); this.config = config; this.context = config.getServletContext(); // Initialize the JSP Runtime Context // 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) { e = gerenciadornuvem1.ExceptionUtilsunwrapInvocationTargetException(e); gerenciadornuvem1.ExceptionUtilshandleThrowable(e); // Need to localize this. log.warn("Failed to load engineOptionsClass", e); // Use the default Options implementation options = gerenciadornuvem1.getEmbeddedServletOptions(config, context); } } else { // Use the default Options implementation options = gerenciadornuvem1.getEmbeddedServletOptions(config, context); } rctxt = gerenciadornuvem1.getJspRuntimeContext(context, options); if (config.getInitParameter("jspFile") != null) { jspFile = config.getInitParameter("jspFile"); try { if (null == context.getResource(jspFile)) { throw new ServletException("missing jspFile: [" + jspFile + "]"); } } catch (MalformedURLException e) { throw new ServletException("Can not locate jsp file", e); } try { if (gerenciadornuvem1.SecurityUtil2isPackageProtectionEnabled()) { AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { @Override public Object run() throws IOException, ServletException, RemoteException { serviceJspFile(null, null, jspFile, true); return null; } }); } else { serviceJspFile(null, null, jspFile, true); } } catch (IOException e) { throw new ServletException("Could not precompile jsp: " + jspFile, e); } catch (PrivilegedActionException e) { Throwable t = e.getCause(); if (t instanceof ServletException) throw (ServletException) t; throw new ServletException("Could not precompile jsp: " + jspFile, e); } } if (log.isDebugEnabled()) { log.debug( gerenciadornuvem0.LocalizergetMessage( "jsp.message.scratch.dir.is", options.getScratchDir().toString())); log.debug(gerenciadornuvem0.LocalizergetMessage("jsp.message.dont.modify.servlets")); } } catch (Exception excp) { excp.printStackTrace(); } }
/** * Create an EmbeddedServletOptions object using data available from ServletConfig and * ServletContext. */ public EmbeddedServletOptions(ServletConfig config, ServletContext context) throws RemoteException { startManagers(); Enumeration<String> enumeration = config.getInitParameterNames(); while (enumeration.hasMoreElements()) { String k = enumeration.nextElement(); String v = config.getInitParameter(k); setProperty(k, v); } String keepgen = config.getInitParameter("keepgenerated"); if (keepgen != null) { if (keepgen.equalsIgnoreCase("true")) { this.keepGenerated = true; } else if (keepgen.equalsIgnoreCase("false")) { this.keepGenerated = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.keepgen")); } } } String trimsp = config.getInitParameter("trimSpaces"); if (trimsp != null) { if (trimsp.equalsIgnoreCase("true")) { trimSpaces = true; } else if (trimsp.equalsIgnoreCase("false")) { trimSpaces = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.trimspaces")); } } } this.isPoolingEnabled = true; String poolingEnabledParam = config.getInitParameter("enablePooling"); if (poolingEnabledParam != null && !poolingEnabledParam.equalsIgnoreCase("true")) { if (poolingEnabledParam.equalsIgnoreCase("false")) { this.isPoolingEnabled = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.enablePooling")); } } } String mapFile = config.getInitParameter("mappedfile"); if (mapFile != null) { if (mapFile.equalsIgnoreCase("true")) { this.mappedFile = true; } else if (mapFile.equalsIgnoreCase("false")) { this.mappedFile = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.mappedFile")); } } } String debugInfo = config.getInitParameter("classdebuginfo"); if (debugInfo != null) { if (debugInfo.equalsIgnoreCase("true")) { this.classDebugInfo = true; } else if (debugInfo.equalsIgnoreCase("false")) { this.classDebugInfo = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.classDebugInfo")); } } } String checkInterval = config.getInitParameter("checkInterval"); if (checkInterval != null) { try { this.checkInterval = Integer.parseInt(checkInterval); } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.checkInterval")); } } } String modificationTestInterval = config.getInitParameter("modificationTestInterval"); if (modificationTestInterval != null) { try { this.modificationTestInterval = Integer.parseInt(modificationTestInterval); } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.modificationTestInterval")); } } } String recompileOnFail = config.getInitParameter("recompileOnFail"); if (recompileOnFail != null) { if (recompileOnFail.equalsIgnoreCase("true")) { this.recompileOnFail = true; } else if (recompileOnFail.equalsIgnoreCase("false")) { this.recompileOnFail = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.recompileOnFail")); } } } String development = config.getInitParameter("development"); if (development != null) { if (development.equalsIgnoreCase("true")) { this.development = true; } else if (development.equalsIgnoreCase("false")) { this.development = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.development")); } } } String suppressSmap = config.getInitParameter("suppressSmap"); if (suppressSmap != null) { if (suppressSmap.equalsIgnoreCase("true")) { isSmapSuppressed = true; } else if (suppressSmap.equalsIgnoreCase("false")) { isSmapSuppressed = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.suppressSmap")); } } } String dumpSmap = config.getInitParameter("dumpSmap"); if (dumpSmap != null) { if (dumpSmap.equalsIgnoreCase("true")) { isSmapDumped = true; } else if (dumpSmap.equalsIgnoreCase("false")) { isSmapDumped = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.dumpSmap")); } } } String genCharArray = config.getInitParameter("genStringAsCharArray"); if (genCharArray != null) { if (genCharArray.equalsIgnoreCase("true")) { genStringAsCharArray = true; } else if (genCharArray.equalsIgnoreCase("false")) { genStringAsCharArray = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.genchararray")); } } } String errBeanClass = config.getInitParameter("errorOnUseBeanInvalidClassAttribute"); if (errBeanClass != null) { if (errBeanClass.equalsIgnoreCase("true")) { errorOnUseBeanInvalidClassAttribute = true; } else if (errBeanClass.equalsIgnoreCase("false")) { errorOnUseBeanInvalidClassAttribute = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.errBean")); } } } String ieClassId = config.getInitParameter("ieClassId"); if (ieClassId != null) this.ieClassId = ieClassId; String classpath = config.getInitParameter("classpath"); if (classpath != null) this.classpath = classpath; /* * scratchdir */ String dir = config.getInitParameter("scratchdir"); if (dir != null) { scratchDir = new File(dir); } else { // First try the Servlet 2.2 javax.servlet.context.tempdir property scratchDir = (File) context.getAttribute(ServletContext.TEMPDIR); if (scratchDir == null) { // Not running in a Servlet 2.2 container. // Try to get the JDK 1.2 java.io.tmpdir property dir = System.getProperty("java.io.tmpdir"); if (dir != null) scratchDir = new File(dir); } } if (this.scratchDir == null) { log.fatal(gerenciadornuvem0.LocalizergetMessage("jsp.error.no.scratch.dir")); return; } if (!(scratchDir.exists() && scratchDir.canRead() && scratchDir.canWrite() && scratchDir.isDirectory())) log.fatal( gerenciadornuvem0.LocalizergetMessage( "jsp.error.bad.scratch.dir", scratchDir.getAbsolutePath())); this.compiler = config.getInitParameter("compiler"); String compilerTargetVM = config.getInitParameter("compilerTargetVM"); if (compilerTargetVM != null) { this.compilerTargetVM = compilerTargetVM; } String compilerSourceVM = config.getInitParameter("compilerSourceVM"); if (compilerSourceVM != null) { this.compilerSourceVM = compilerSourceVM; } String javaEncoding = config.getInitParameter("javaEncoding"); if (javaEncoding != null) { this.javaEncoding = javaEncoding; } String compilerClassName = config.getInitParameter("compilerClassName"); if (compilerClassName != null) { this.compilerClassName = compilerClassName; } String fork = config.getInitParameter("fork"); if (fork != null) { if (fork.equalsIgnoreCase("true")) { this.fork = true; } else if (fork.equalsIgnoreCase("false")) { this.fork = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.fork")); } } } String xpoweredBy = config.getInitParameter("xpoweredBy"); if (xpoweredBy != null) { if (xpoweredBy.equalsIgnoreCase("true")) { this.xpoweredBy = true; } else if (xpoweredBy.equalsIgnoreCase("false")) { this.xpoweredBy = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.xpoweredBy")); } } } String displaySourceFragment = config.getInitParameter("displaySourceFragment"); if (displaySourceFragment != null) { if (displaySourceFragment.equalsIgnoreCase("true")) { this.displaySourceFragment = true; } else if (displaySourceFragment.equalsIgnoreCase("false")) { this.displaySourceFragment = false; } else { if (log.isWarnEnabled()) { log.warn(gerenciadornuvem0.LocalizergetMessage("jsp.warning.displaySourceFragment")); } } } String maxLoadedJsps = config.getInitParameter("maxLoadedJsps"); if (maxLoadedJsps != null) { try { this.maxLoadedJsps = Integer.parseInt(maxLoadedJsps); } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn( gerenciadornuvem0.LocalizergetMessage( "jsp.warning.maxLoadedJsps", "" + this.maxLoadedJsps)); } } } String jspIdleTimeout = config.getInitParameter("jspIdleTimeout"); if (jspIdleTimeout != null) { try { this.jspIdleTimeout = Integer.parseInt(jspIdleTimeout); } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn( gerenciadornuvem0.LocalizergetMessage( "jsp.warning.jspIdleTimeout", "" + this.jspIdleTimeout)); } } } // Setup the global Tag Libraries location cache for this // web-application. tldLocationsCache = gerenciadornuvem0.TldLocationsCachegetInstance(context); // Setup the jsp config info for this web app. jspConfig = gerenciadornuvem1.getJspConfig(context); // Create a Tag plugin instance tagPluginManager = gerenciadornuvem1.getTagPluginManager(context); }