org.apache.struts2.jasper.servlet

## Class JspServletWrapper

- java.lang.Object
- - org.apache.struts2.jasper.servlet.JspServletWrapper

-     public class JspServletWrapper
      extends Object

  The JSP engine (a.k.a Jasper). The servlet container is responsible for providing a URLClassLoader for the web application context Jasper is being used in. Jasper will try 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.
  Author:
    Anil K. Vijendran, Harish Prabandham, Remy Maucherat, Kin-man Chung, Glenn Nielsen, Tim Fennell

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JspServletWrapper(javax.servlet.ServletConfig config, Options options, String jspUri, boolean isErrorPage, JspRuntimeContext rctxt)`
    `JspServletWrapper(javax.servlet.ServletContext servletContext, Options options, String tagFilePath, javax.servlet.jsp.tagext.TagInfo tagInfo, JspRuntimeContext rctxt, URL tagFileJarUrl)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `decTripCount()`
    `void` | `destroy()`
    `List` | `getDependants()` Get a list of files that the current page has source dependency on.
    `JspCompilationContext` | `getJspEngineContext()`
    `long` | `getLastModificationTest()`
    `javax.servlet.Servlet` | `getServlet()`
    `javax.servlet.ServletContext` | `getServletContext()`
    `protected JasperException` | `handleJspException(Exception ex)` Attempts to construct a JasperException that contains helpful information about what went wrong.
    `int` | `incTripCount()`
    `boolean` | `isTagFile()`
    `Class` | `loadTagFile()` Compile (if needed) and load a tag file
    `Class` | `loadTagFilePrototype()` Compile and load a prototype for the Tag file.
    `void` | `service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean precompile)`
    `void` | `setCompilationException(JasperException je)` Sets the compilation exception for this JspServletWrapper.
    `void` | `setLastModificationTest(long lastModificationTest)`
    `void` | `setReload(boolean reload)`
    `void` | `setServletClassLastModifiedTime(long lastModified)` Sets the last-modified time of the servlet class file associated with this JspServletWrapper.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JspServletWrapper

          public JspServletWrapper(javax.servlet.ServletConfig config,
                                   Options options,
                                   String jspUri,
                                   boolean isErrorPage,
                                   JspRuntimeContext rctxt)
                            throws JasperException

      Throws:
        `JasperException`

    - #### JspServletWrapper

          public JspServletWrapper(javax.servlet.ServletContext servletContext,
                                   Options options,
                                   String tagFilePath,
                                   javax.servlet.jsp.tagext.TagInfo tagInfo,
                                   JspRuntimeContext rctxt,
                                   URL tagFileJarUrl)
                            throws JasperException

      Throws:
        `JasperException`

  - ### Method Detail

    - #### getJspEngineContext

          public JspCompilationContext getJspEngineContext()

    - #### setReload

          public void setReload(boolean reload)

    - #### getServlet

          public javax.servlet.Servlet getServlet()
                                           throws javax.servlet.ServletException,
                                                  IOException,
                                                  FileNotFoundException

      Throws:
        `javax.servlet.ServletException`
        `IOException`
        `FileNotFoundException`

    - #### getServletContext

          public javax.servlet.ServletContext getServletContext()

    - #### 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 Class loadTagFile()
                            throws JasperException

      Compile (if needed) and load a tag file
      Throws:
        `JasperException`

    - #### loadTagFilePrototype

          public Class loadTagFilePrototype()
                                     throws JasperException

      Compile and load a prototype for the Tag file. This is needed when compiling tag files with circular dependencies. A prototpe (skeleton) with no dependencies on other other tag files is generated and compiled.
      Throws:
        `JasperException`

    - #### getDependants

          public List getDependants()

      Get a list of files that the current page has source dependency on.

    - #### isTagFile

          public boolean isTagFile()

    - #### incTripCount

          public int incTripCount()

    - #### decTripCount

          public int decTripCount()

    - #### service

          public void service(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response,
                              boolean precompile)
                       throws javax.servlet.ServletException,
                              IOException,
                              FileNotFoundException

      Throws:
        `javax.servlet.ServletException`
        `IOException`
        `FileNotFoundException`

    - #### destroy

          public void destroy()

    - #### getLastModificationTest

          public long getLastModificationTest()

      Returns:
        Returns the lastModificationTest.

    - #### setLastModificationTest

          public void setLastModificationTest(long lastModificationTest)

      Parameters:
        `lastModificationTest` - The lastModificationTest to set.

    - #### handleJspException

          protected JasperException handleJspException(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 http://issues.apache.org/bugzilla/show_bug.cgi?id=37062 and http://www.tfenne.com/jasper/ for more details.

      Parameters:
        `ex` - the exception that was the cause of the problem.
      Returns:
        a JasperException with more detailed information

Copyright © 2000–2025 Apache Software Foundation. All rights reserved.