JspServlet (Apache Tomcat 10.1.57 API Documentation)
Description: declaration: package: org.apache.jasper.servlet, class: JspServlet

# Class JspServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.jasper.servlet.JspServlet

All Implemented Interfaces:
  `Servlet, ServletConfig, Serializable, PeriodicEventListener`

public class JspServlet extends HttpServlet implements PeriodicEventListener
The 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.

See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class HttpServlet

  `LEGACY_DO_HEAD`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JspServlet()`
  Default constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `destroy()`
  Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
  `int`
  `getJspCount()`
  Returns the number of JSPs for which JspServletWrappers exist, i.e., the number of JSPs that have been loaded into the webapp with which this JspServlet is associated.
  `int`
  `getJspQueueLength()`
  Gets the number of JSPs that are in the JSP limiter queue
  `int`
  `getJspReloadCount()`
  Gets the number of JSPs that have been reloaded.
  `int`
  `getJspUnloadCount()`
  Gets the number of JSPs that have been unloaded.
  `void`
  `init(ServletConfig config)`
  Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
  `void`
  `periodicEvent()`
  Execute a periodic task, such as reloading, etc.
  `void`
  `service(HttpServletRequest request, HttpServletResponse response)`
  Receives standard HTTP requests from the public `service` method and dispatches them to the `do`Method methods defined in this class.
  `void`
  `setJspReloadCount(int count)`
  Resets the JSP reload counter.

  ### Methods inherited from class HttpServlet

  `doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service`

  ### Methods inherited from class GenericServlet

  `getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### JspServlet

    public JspServlet()
    Default constructor.

- ## Method Details

  - ### init

    public void init(ServletConfig config) throws ServletException
    Description copied from class: `jakarta.servlet.GenericServlet`
    Called by the servlet container to indicate to a servlet that the servlet is being placed into service. See `Servlet.init(ServletConfig)`.

    This implementation stores the `ServletConfig` object it receives from the servlet container for later use. When overriding this form of the method, call `super.init(config)`.

    Specified by:
      `init` in interface `Servlet`
    Overrides:
      `init` in class `HttpServlet`
    Parameters:
      `config` - the `ServletConfig` object that contains configuration information for this servlet
    Throws:
      `ServletException` - if an exception occurs that interrupts the servlet's normal operation
    See Also:
      - `UnavailableException`

  - ### getJspCount

    public int getJspCount()
    Returns the number of JSPs for which JspServletWrappers exist, i.e., the number of JSPs that have been loaded into the webapp with which this JspServlet is associated.

    This info may be used for monitoring purposes.

    Returns:
      The number of JSPs that have been loaded into the webapp with which this JspServlet is associated

  - ### setJspReloadCount

    public void setJspReloadCount(int count)
    Resets the JSP reload counter.
    Parameters:
      `count` - Value to which to reset the JSP reload counter

  - ### getJspReloadCount

    public int getJspReloadCount()
    Gets the number of JSPs that have been reloaded.

    This info may be used for monitoring purposes.

    Returns:
      The number of JSPs (in the webapp with which this JspServlet is associated) that have been reloaded

  - ### getJspQueueLength

    public int getJspQueueLength()
    Gets the number of JSPs that are in the JSP limiter queue

    This info may be used for monitoring purposes.

    Returns:
      The number of JSPs (in the webapp with which this JspServlet is associated) that are in the JSP limiter queue

  - ### getJspUnloadCount

    public int getJspUnloadCount()
    Gets the number of JSPs that have been unloaded.

    This info may be used for monitoring purposes.

    Returns:
      The number of JSPs (in the webapp with which this JspServlet is associated) that have been unloaded

  - ### service

    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    Description copied from class: `jakarta.servlet.http.HttpServlet`
    Receives standard HTTP requests from the public `service` method and dispatches them to the `do`Method methods defined in this class. This method is an HTTP-specific version of the `Servlet.service(ServletRequest, ServletResponse)` method. There's no need to override this method.
    Overrides:
      `service` in class `HttpServlet`
    Parameters:
      `request` - the `HttpServletRequest` object that contains the request the client made of the servlet
      `response` - the `HttpServletResponse` object that contains the response the servlet returns to the client
    Throws:
      `ServletException` - if the HTTP request cannot be handled
      `IOException` - if an input or output error occurs while the servlet is handling the HTTP request
    See Also:
      - `Servlet.service(ServletRequest, ServletResponse)`

  - ### destroy

    public void destroy()
    Description copied from class: `jakarta.servlet.GenericServlet`
    Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. See `Servlet.destroy()`.
    Specified by:
      `destroy` in interface `Servlet`
    Overrides:
      `destroy` in class `GenericServlet`

  - ### periodicEvent

    public void periodicEvent()
    Description copied from interface: `PeriodicEventListener`
    Execute a periodic task, such as reloading, etc.
    Specified by:
      `periodicEvent` in interface `PeriodicEventListener`