protected JspCompilationContext createJspCompilationContext( String name, boolean isErrPage, Options opt, ServletContext sctx, JspRuntimeContext jrctx, ClassLoader cl) { JspCompilationContext jcctx = new JspCompilationContext(name, opt, sctx, null, jrctx); jcctx.setClassLoader(cl); return jcctx; }
protected void processFile(String file) throws JasperException { if (log.isDebugEnabled()) { log.debug("Processing file: " + file); } ClassLoader originalClassLoader = null; try { // set up a scratch/output dir if none is provided if (scratchDir == null) { String temp = System.getProperty("java.io.tmpdir"); if (temp == null) { temp = ""; } scratchDir = new File(new File(temp).getAbsolutePath()); } String jspUri = file.replace('\\', '/'); JspCompilationContext clctxt = new JspCompilationContext(jspUri, this, context, null, rctxt); /* Override the defaults */ if ((targetClassName != null) && (targetClassName.length() > 0)) { clctxt.setServletClassName(targetClassName); targetClassName = null; } if (targetPackage != null) { clctxt.setServletPackageName(targetPackage); } originalClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(loader); clctxt.setClassLoader(loader); clctxt.setClassPath(classPath); Compiler clc = clctxt.createCompiler(); // If compile is set, generate both .java and .class, if // .jsp file is newer than .class file; // Otherwise only generate .java, if .jsp file is newer than // the .java file if (clc.isOutDated(compile)) { if (log.isDebugEnabled()) { log.debug(jspUri + " is out dated, compiling..."); } clc.compile(compile, true); } // Generate mapping generateWebMapping(file, clctxt); if (showSuccess) { log.info("Built File: " + file); } } catch (JasperException je) { Throwable rootCause = je; while (rootCause instanceof JasperException && ((JasperException) rootCause).getRootCause() != null) { rootCause = ((JasperException) rootCause).getRootCause(); } if (rootCause != je) { log.error(Localizer.getMessage("jspc.error.generalException", file), rootCause); } // Bugzilla 35114. if (getFailOnError()) { throw je; } else { log.error(je.getMessage()); } } catch (Exception e) { if ((e instanceof FileNotFoundException) && log.isWarnEnabled()) { log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist", e.getMessage())); } throw new JasperException(e); } finally { if (originalClassLoader != null) { Thread.currentThread().setContextClassLoader(originalClassLoader); } } }