Package org.apache.jasper.servlet
Class JspServletWrapper
- java.lang.Object
-
- org.apache.jasper.servlet.JspServletWrapper
-
public class JspServletWrapper extends java.lang.ObjectThe Jasper JSP engine. The servlet container is responsible for providing a URLClassLoader for the web application context Jasper is being used in. Jasper will try to get the Tomcat ServletContext attribute for its ServletContext class loader, if that fails, it uses the parent class loader. In either case, it must be a URLClassLoader.
-
-
Constructor Summary
Constructors Constructor Description JspServletWrapper(ServletConfig config, Options options, java.lang.String jspUri, JspRuntimeContext rctxt)Constructs a JspServletWrapper for JSP pages.JspServletWrapper(ServletContext servletContext, Options options, java.lang.String tagFilePath, TagInfo tagInfo, JspRuntimeContext rctxt, Jar tagJar)Constructs a JspServletWrapper for tag files.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intdecTripCount()Decrements and returns the trip count.voiddestroy()Destroys the wrapped servlet, if any.java.util.Map<java.lang.String,java.lang.Long>getDependants()Get a list of files that the current page has source dependency on.JspCompilationContextgetJspEngineContext()Returns the JSP compilation context.java.lang.StringgetJspUri()Returns the JSP URI.longgetLastModificationTest()Returns the timestamp of the last modification test.longgetLastUsageTime()Returns the timestamp of the last usage.booleangetReload()Returns the reload flag.ServletgetServlet()Gets the servlet, compiling and loading it if necessary.ServletContextgetServletContext()Returns the servlet context.FastRemovalDequeue.EntrygetUnloadHandle()Returns the unload handle for managing JSP unloading.protected JasperExceptionhandleJspException(java.lang.Exception ex)Attempts to construct a JasperException that contains helpful information about what went wrong.intincTripCount()Increments and returns the trip count.booleanisTagFile()Returns whether this wrapper is for a tag file.java.lang.Class<?>loadTagFile()Compile (if needed) and load a tag file.java.lang.Class<?>loadTagFilePrototype()Compile and load a prototype for the Tag file.voidservice(HttpServletRequest request, HttpServletResponse response, boolean precompile)Services the request, compiling and loading the servlet if necessary.voidsetCompilationException(JasperException je)Sets the compilation exception for this JspServletWrapper.voidsetLastModificationTest(long lastModificationTest)Sets the timestamp of the last modification test.voidsetReload(boolean reload)Sets the reload flag.voidsetServletClassLastModifiedTime(long lastModified)Sets the last-modified time of the servlet class file associated with this JspServletWrapper.
-
-
-
Constructor Detail
-
JspServletWrapper
public JspServletWrapper(ServletConfig config, Options options, java.lang.String jspUri, JspRuntimeContext rctxt)
Constructs a JspServletWrapper for JSP pages.- Parameters:
config- The servlet configoptions- The optionsjspUri- The JSP URIrctxt- The runtime context
-
JspServletWrapper
public JspServletWrapper(ServletContext servletContext, Options options, java.lang.String tagFilePath, TagInfo tagInfo, JspRuntimeContext rctxt, Jar tagJar)
Constructs a JspServletWrapper for tag files.- Parameters:
servletContext- The servlet contextoptions- The optionstagFilePath- The tag file pathtagInfo- The tag inforctxt- The runtime contexttagJar- The tag JAR
-
-
Method Detail
-
getJspEngineContext
public JspCompilationContext getJspEngineContext()
Returns the JSP compilation context.- Returns:
- the compilation context
-
setReload
public void setReload(boolean reload)
Sets the reload flag.- Parameters:
reload- The reload flag
-
getReload
public boolean getReload()
Returns the reload flag.- Returns:
- the reload flag
-
getServlet
public Servlet getServlet() throws ServletException
Gets the servlet, compiling and loading it if necessary.- Returns:
- the servlet
- Throws:
ServletException- if an error occurs
-
getServletContext
public ServletContext getServletContext()
Returns the servlet context.- Returns:
- the servlet context
-
setCompilationException
public void setCompilationException(JasperException je)
Sets the compilation exception for this JspServletWrapper.- Parameters:
je- The compilation exception
-
setServletClassLastModifiedTime
public void setServletClassLastModifiedTime(long lastModified)
Sets the last-modified time of the servlet class file associated with this JspServletWrapper.- Parameters:
lastModified- Last-modified time of servlet class
-
loadTagFile
public java.lang.Class<?> loadTagFile() throws JasperExceptionCompile (if needed) and load a tag file.- Returns:
- the loaded class
- Throws:
JasperException- Error compiling or loading tag file
-
loadTagFilePrototype
public java.lang.Class<?> loadTagFilePrototype() throws JasperExceptionCompile and load a prototype for the Tag file. This is needed when compiling tag files with circular dependencies. A prototype (skeleton) with no dependencies on other tag files is generated and compiled.- Returns:
- the loaded class
- Throws:
JasperException- Error compiling or loading tag file
-
getDependants
public java.util.Map<java.lang.String,java.lang.Long> getDependants()
Get a list of files that the current page has source dependency on.- Returns:
- the map of dependent resources
-
isTagFile
public boolean isTagFile()
Returns whether this wrapper is for a tag file.- Returns:
trueif this is a tag file
-
incTripCount
public int incTripCount()
Increments and returns the trip count.- Returns:
- the trip count before incrementing
-
decTripCount
public int decTripCount()
Decrements and returns the trip count.- Returns:
- the trip count after decrementing
-
getJspUri
public java.lang.String getJspUri()
Returns the JSP URI.- Returns:
- the JSP URI
-
getUnloadHandle
public FastRemovalDequeue.Entry getUnloadHandle()
Returns the unload handle for managing JSP unloading.- Returns:
- the unload handle
-
service
public void service(HttpServletRequest request, HttpServletResponse response, boolean precompile) throws ServletException, java.io.IOException, java.io.FileNotFoundException
Services the request, compiling and loading the servlet if necessary.- Parameters:
request- The HTTP requestresponse- The HTTP responseprecompile- Whether this is a precompile-only request- Throws:
ServletException- if a servlet error occursjava.io.IOException- if an I/O error occursjava.io.FileNotFoundException- if the JSP file is not found
-
destroy
public void destroy()
Destroys the wrapped servlet, if any.
-
getLastModificationTest
public long getLastModificationTest()
Returns the timestamp of the last modification test.- Returns:
- the timestamp of the last modification test
-
setLastModificationTest
public void setLastModificationTest(long lastModificationTest)
Sets the timestamp of the last modification test.- Parameters:
lastModificationTest- The timestamp to set
-
getLastUsageTime
public long getLastUsageTime()
Returns the timestamp of the last usage.- Returns:
- the timestamp of the last usage
-
handleJspException
protected JasperException handleJspException(java.lang.Exception ex)
Attempts to construct a JasperException that contains helpful information about what went wrong. Uses the JSP compiler system to translate the line number in the generated servlet that originated the exception to a line number in the JSP. Then constructs an exception containing that information, and a snippet of the JSP to help debugging. Please see BZ 37062 for more details.
- Parameters:
ex- the exception that was the cause of the problem.- Returns:
- a JasperException with more detailed information
-
-