if (smap == null && !options.isSmapSuppressed()) { // Tomcat was restarted so cached SMAP has been lost. However, it // was written to the class file so it can be recovered.
smap = SmapUtil.loadSmap(className, ctxt.getJspLoader()); if (smap != null) {
smaps.put(className, smap);
}
}
// Pass 2 - the whole translation unit
pageNodes = parserCtl.parse(ctxt.getJspFile());
// Leave this until now since it can only be set once - bug 49726 if (pageInfo.getContentType() == null &&
jspProperty.getDefaultContentType() != null) {
pageInfo.setContentType(jspProperty.getDefaultContentType());
}
if (ctxt.isPrototypeMode()) { // generate prototype .java file for the tag file try (ServletWriter writer = setupContextWriter(javaFileName)) {
Generator.generate(writer, this, pageNodes); returnnull;
}
}
// Validate and process attributes - don't re-validate the // directives we validated in pass 1
Validator.validateExDirectives(this, pageNodes);
if (log.isDebugEnabled()) {
t2 = System.currentTimeMillis();
}
// Collect page info
Collector.collect(this, pageNodes);
// Compile (if necessary) and load the tag files referenced in // this compilation unit.
tfp = new TagFileProcessor();
tfp.loadTagFiles(this, pageNodes);
if (log.isDebugEnabled()) {
t3 = System.currentTimeMillis();
}
// Determine which custom tag needs to declare which scripting vars
ScriptingVariabler.set(pageNodes, errDispatcher);
// Optimizations by Tag Plugins
TagPluginManager tagPluginManager = options.getTagPluginManager();
tagPluginManager.apply(pageNodes, errDispatcher, pageInfo);
// The writer is only used during the compile, dereference // it in the JspCompilationContext when done to allow it // to be GC'd and save memory.
ctxt.setWriter(null);
} catch (RuntimeException e) { // Remove the generated .java file
File file = new File(javaFileName); if (file.exists()) { if (!file.delete()) {
log.warn(Localizer.getMessage( "jsp.warning.compiler.javafile.delete.fail",
file.getAbsolutePath()));
}
} throw e;
}
Map<String,SmapStratum> smaps = null;
// JSR45 Support if (!options.isSmapSuppressed()) {
smaps = SmapUtil.generateSmap(ctxt, pageNodes); // Add them to the web application wide cache for future lookup in // error handling etc.
ctxt.getRuntimeContext().getSmaps().putAll(smaps);
}
// If any proto type .java and .class files was generated, // the prototype .java may have been replaced by the current // compilation (if the tag file is self referencing), but the // .class file need to be removed, to make sure that javac would // generate .class again from the new .java file just generated.
tfp.removeProtoTypeFiles(ctxt.getClassFileName());
try { finalLong jspLastModified = ctxt.getLastModified(ctxt.getJspFile());
Map<String,SmapStratum> smaps = generateJava();
File javaFile = new File(ctxt.getServletJavaFileName()); if (!javaFile.setLastModified(jspLastModified.longValue())) { thrownew JasperException(Localizer.getMessage("jsp.error.setLastModified", javaFile));
} if (compileClass) {
generateClass(smaps); // Fix for bugzilla 41606 // Set JspServletWrapper.servletClassLastModifiedTime after successful compile
File targetFile = new File(ctxt.getClassFileName()); if (targetFile.exists()) { if (!targetFile.setLastModified(jspLastModified.longValue())) { thrownew JasperException(
Localizer.getMessage("jsp.error.setLastModified", targetFile));
} if (jsw != null) {
jsw.setServletClassLastModifiedTime(
jspLastModified.longValue());
}
}
}
} finally { if (tfp != null && ctxt.isPrototypeMode()) {
tfp.removeProtoTypeFiles(null);
} // Make sure these object which are only used during the // generation and compilation of the JSP page get // dereferenced so that they can be GC'd and reduce the // memory footprint.
tfp = null;
errDispatcher = null;
pageInfo = null;
pageNodes = null;
if (ctxt.getWriter() != null) {
ctxt.getWriter().close();
ctxt.setWriter(null);
}
}
}
if (jsw != null
&& (ctxt.getOptions().getModificationTestInterval() > 0)) {
if (jsw.getLastModificationTest()
+ (ctxt.getOptions().getModificationTestInterval() * 1000) > System
.currentTimeMillis()) { returnfalse;
}
jsw.setLastModificationTest(System.currentTimeMillis());
}
// Test the target file first. Unless there is an error checking the // last modified time of the source (unlikely) the target is going to // have to be checked anyway. If the target doesn't exist (likely during // startup) this saves an unnecessary check of the source.
File targetFile; if (checkClass) {
targetFile = new File(ctxt.getClassFileName());
} else {
targetFile = new File(ctxt.getServletJavaFileName());
} if (!targetFile.exists()) { returntrue;
} long targetLastModified = targetFile.lastModified(); if (checkClass && jsw != null) {
jsw.setServletClassLastModifiedTime(targetLastModified);
}
Long jspRealLastModified = ctxt.getLastModified(ctxt.getJspFile()); if (jspRealLastModified.longValue() < 0) { // Something went wrong - assume modification returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.