org.apache.catalina.servlet4preview

## Interface ServletContext

- All Superinterfaces:
    ServletContext

      public interface ServletContext
      extends ServletContext

- - ### Field Summary

    - ### Fields inherited from interface javax.servlet.ServletContext

      `ORDERED_LIBS, TEMPDIR`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ServletRegistration.Dynamic` | `addJspFile(String jspName, String jspFile)`
    `String` | `getRequestCharacterEncoding()` Get the default character encoding for reading request bodies.
    `String` | `getResponseCharacterEncoding()` Get the default character encoding for writing response bodies.
    `int` | `getSessionTimeout()` Get the default session timeout.
    `void` | `setRequestCharacterEncoding(String encoding)` Set the default character encoding to use for reading request bodies.
    `void` | `setResponseCharacterEncoding(String encoding)` Set the default character encoding to use for writing response bodies.
    `void` | `setSessionTimeout(int sessionTimeout)` Set the default session timeout.

    - ### Methods inherited from interface javax.servlet.ServletContext

      `addFilter, addFilter, addFilter, addListener, addListener, addListener, addServlet, addServlet, addServlet, createFilter, createListener, createServlet, declareRoles, getAttribute, getAttributeNames, getClassLoader, getContext, getContextPath, getDefaultSessionTrackingModes, getEffectiveMajorVersion, getEffectiveMinorVersion, getEffectiveSessionTrackingModes, getFilterRegistration, getFilterRegistrations, getInitParameter, getInitParameterNames, getJspConfigDescriptor, getMajorVersion, getMimeType, getMinorVersion, getNamedDispatcher, getRealPath, getRequestDispatcher, getResource, getResourceAsStream, getResourcePaths, getServerInfo, getServlet, getServletContextName, getServletNames, getServletRegistration, getServletRegistrations, getServlets, getSessionCookieConfig, getVirtualServerName, log, log, log, removeAttribute, setAttribute, setInitParameter, setSessionTrackingModes`

- - ### Method Detail

    - #### getSessionTimeout

          int getSessionTimeout()

      Get the default session timeout.
      Returns:
        The current default session timeout in minutes
      Throws:
        `UnsupportedOperationException` - If called from a `ServletContextListener.contextInitialized(ServletContextEvent)` method of a `ServletContextListener` that was not defined in a web.xml file, a web-fragment.xml file nor annotated with `WebListener`. For example, a `ServletContextListener` defined in a TLD would not be able to use this method.
      Since:
        Servlet 4.0

    - #### setSessionTimeout

          void setSessionTimeout(int sessionTimeout)

      Set the default session timeout. This method may only be called before the ServletContext is initialised.
      Parameters:
        `sessionTimeout` - The new default session timeout in minutes.
      Throws:
        `UnsupportedOperationException` - If called from a `ServletContextListener.contextInitialized(ServletContextEvent)` method of a `ServletContextListener` that was not defined in a web.xml file, a web-fragment.xml file nor annotated with `WebListener`. For example, a `ServletContextListener` defined in a TLD would not be able to use this method.
        `IllegalStateException` - If the ServletContext has already been initialised
      Since:
        Servlet 4.0

    - #### addJspFile

          ServletRegistration.Dynamic addJspFile(String jspName,
                                               String jspFile)

      Parameters:
        `jspName` - The servlet name under which this JSP file should be registered
        `jspFile` - The path, relative to the web application root, for the JSP file to be used for this servlet
      Returns:
        a `ServletRegistration.Dynamic` object that can be used to further configure the servlet
      Since:
        Servlet 4.0

    - #### getRequestCharacterEncoding

          String getRequestCharacterEncoding()

      Get the default character encoding for reading request bodies.
      Returns:
        The character encoding name or `null` if no default has been specified
      Throws:
        `UnsupportedOperationException` - If called from a `ServletContextListener.contextInitialized(ServletContextEvent)` method of a `ServletContextListener` that was not defined in a web.xml file, a web-fragment.xml file nor annotated with `WebListener`. For example, a `ServletContextListener` defined in a TLD would not be able to use this method.
      Since:
        Servlet 4.0

    - #### setRequestCharacterEncoding

          void setRequestCharacterEncoding(String encoding)

      Set the default character encoding to use for reading request bodies. Calling this method will over-ride any value set in the deployment descriptor.
      Parameters:
        `encoding` - The name of the character encoding to use
      Throws:
        `UnsupportedOperationException` - If called from a `ServletContextListener.contextInitialized(ServletContextEvent)` method of a `ServletContextListener` that was not defined in a web.xml file, a web-fragment.xml file nor annotated with `WebListener`. For example, a `ServletContextListener` defined in a TLD would not be able to use this method.
        `IllegalStateException` - If the ServletContext has already been initialised
      Since:
        Servlet 4.0

    - #### getResponseCharacterEncoding

          String getResponseCharacterEncoding()

      Get the default character encoding for writing response bodies.
      Returns:
        The character encoding name or `null` if no default has been specified
      Throws:
        `UnsupportedOperationException` - If called from a `ServletContextListener.contextInitialized(ServletContextEvent)` method of a `ServletContextListener` that was not defined in a web.xml file, a web-fragment.xml file nor annotated with `WebListener`. For example, a `ServletContextListener` defined in a TLD would not be able to use this method.
      Since:
        Servlet 4.0

    - #### setResponseCharacterEncoding

          void setResponseCharacterEncoding(String encoding)

      Set the default character encoding to use for writing response bodies. Calling this method will over-ride any value set in the deployment descriptor.
      Parameters:
        `encoding` - The name of the character encoding to use
      Throws:
        `UnsupportedOperationException` - If called from a `ServletContextListener.contextInitialized(ServletContextEvent)` method of a `ServletContextListener` that was not defined in a web.xml file, a web-fragment.xml file nor annotated with `WebListener`. For example, a `ServletContextListener` defined in a TLD would not be able to use this method.
        `IllegalStateException` - If the ServletContext has already been initialised
      Since:
        Servlet 4.0

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.