Class JspServletWrapper

java.lang.Object
org.apache.sling.scripting.jsp.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 Details

    • JspServletWrapper

      public JspServletWrapper(javax.servlet.ServletConfig config, Options options, String jspUri, boolean isErrorPage, JspRuntimeContext rctxt)
      JspServletWrapper for JSP pages.
    • JspServletWrapper

      public JspServletWrapper(javax.servlet.ServletConfig config, Options options, String jspUri, boolean isErrorPage, JspRuntimeContext rctxt, javax.servlet.Servlet servlet)
      JspServletWrapper for precompiled JSPs
    • JspServletWrapper

      public JspServletWrapper(javax.servlet.ServletContext servletContext, Options options, String tagFilePath, javax.servlet.jsp.tagext.TagInfo tagInfo, JspRuntimeContext rctxt, URL tagFileJarUrl) throws JasperException
      JspServletWrapper for tag files.
      Throws:
      JasperException
  • Method Details

    • getJspEngineContext

      public JspCompilationContext getJspEngineContext()
    • isValid

      public boolean isValid()
    • getDependencyFilePath

      public String getDependencyFilePath()
      Get the name of the dependencies file.
    • 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<String> 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()
    • getJspUri

      public String getJspUri()
    • service

      public void service(SlingBindings bindings)
      Call the jsp
      Parameters:
      bindings - The bindings for the jsp
      Throws:
      org.apache.sling.scripting.jsp.SlingPageException - JSP page exception handler exceptions
      SlingException - for any non runtime exception
      RuntimeException - for runtime exceptions
    • destroy

      public void destroy(boolean deleteGeneratedFiles)
      Destroy this wrapper
      Parameters:
      deleteGeneratedFiles - Should generated files be deleted as well?
    • handleJspException

      protected void 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.
      Throws:
      a - SlingException Wrapping the original exception