Interface ServletContext

All Known Subinterfaces:
WebApplication
All Known Implementing Classes:
CrossContextWebApplication, DefaultWebApplication, MicroWebApplication

public interface ServletContext
The servlet context API.
Author:
Manfred Riem ([email protected])
  • Field Details

  • Method Details

    • addFilter

      FilterRegistration.Dynamic addFilter(String filterName, String className)
      Add the filter.
      Parameters:
      filterName - the filter name.
      className - the class name.
      Returns:
      the dynamic filter registration.
    • addFilter

      FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
      Add the filter.
      Parameters:
      filterName - the filter name.
      filter - the filter.
      Returns:
      the dynamic filter registration.
    • addFilter

      FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
      Add the filter.
      Parameters:
      filterName - the filter name.
      filterClass - the filter class.
      Returns:
      the dynamic filter registration.
    • addJspFile

      ServletRegistration.Dynamic addJspFile(String servletName, String jspFile)
      Add a JSP file.
      Parameters:
      servletName - the name of the servlet to be used.
      jspFile - the path of the JSP file.
      Returns:
      the dynamic servlet registration.
    • addListener

      void addListener(String className)
      Add the listener.
      Parameters:
      className - the class name.
    • addListener

      <T extends EventListener> void addListener(T listener)
      Add the listener.
      Type Parameters:
      T - the type.
      Parameters:
      listener - the listener.
    • addListener

      void addListener(Class<? extends EventListener> listenerClass)
      Add the listener.
      Parameters:
      listenerClass - the listener class.
    • addServlet

      ServletRegistration.Dynamic addServlet(String servletName, String className)
      Add the servlet.
      Parameters:
      servletName - the servlet name.
      className - the class name.
      Returns:
      the servlet dynamic registration.
    • addServlet

      ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
      Add the servlet.
      Parameters:
      servletName - the servlet name.
      servlet - the servlet.
      Returns:
      the dynamic servlet registration.
    • addServlet

      ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
      Add the servlet.
      Parameters:
      servletName - the servlet name.
      servletClass - the servlet class.
      Returns:
      the dynamic servlet registration.
    • createFilter

      <T extends Filter> T createFilter(Class<T> clazz) throws ServletException
      Create the filter.
      Type Parameters:
      T - the filter type.
      Parameters:
      clazz - the class.
      Returns:
      the filter.
      Throws:
      ServletException - when a servlet error occurs.
    • createListener

      <T extends EventListener> T createListener(Class<T> clazz) throws ServletException
      Create the listener.
      Type Parameters:
      T - the listener type.
      Parameters:
      clazz - the class.
      Returns:
      the listener.
      Throws:
      ServletException - when a servlet error occurs.
    • createServlet

      <T extends Servlet> T createServlet(Class<T> clazz) throws ServletException
      Create the servlet.
      Type Parameters:
      T - the servlet type.
      Parameters:
      clazz - the class.
      Returns:
      the created servlet.
      Throws:
      ServletException - when a servlet error occurs.
    • declareRoles

      void declareRoles(String... roles)
      Declare the roles.
      Parameters:
      roles - the roles.
    • getAttribute

      Object getAttribute(String name)
      Get the attribute.
      Parameters:
      name - the name.
      Returns:
      the value, or null.
    • getAttributeNames

      Enumeration<String> getAttributeNames()
      Returns the attribute names.
      Returns:
      the attribute names
    • getClassLoader

      ClassLoader getClassLoader()
      Returns the class loader.
      Returns:
      the class loader
    • getContext

      ServletContext getContext(String path)
      Get the servlet context for the given path.
      Parameters:
      path - the path.
      Returns:
      the servlet context, or null if not found (or not supported).
    • getContextPath

      String getContextPath()
      Returns the context path.
      Returns:
      the context path
    • getDefaultSessionTrackingModes

      Set<SessionTrackingMode> getDefaultSessionTrackingModes()
      Returns the default session tracking modes.
      Returns:
      the default session tracking modes
    • getEffectiveMajorVersion

      int getEffectiveMajorVersion()
      Returns the effective major version.
      Returns:
      the effective major version
    • getEffectiveMinorVersion

      int getEffectiveMinorVersion()
      Returns the effective minor version.
      Returns:
      the effective minor version
    • getEffectiveSessionTrackingModes

      Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
      Returns the effective session tracking modes.
      Returns:
      the effective session tracking modes
    • getFilterRegistration

      FilterRegistration getFilterRegistration(String filterName)
      Get the filter registration.
      Parameters:
      filterName - the filter name.
      Returns:
      the
    • getFilterRegistrations

      Map<String,​? extends FilterRegistration> getFilterRegistrations()
      Returns the filter registrations.
      Returns:
      the filter registrations
    • getInitParameter

      String getInitParameter(String name)
      Get the init parameter.
      Parameters:
      name - the name.
      Returns:
      the value, or null if not found.
    • getInitParameterNames

      Enumeration<String> getInitParameterNames()
      Returns the init parameter names.
      Returns:
      the init parameter names
    • getJspConfigDescriptor

      JspConfigDescriptor getJspConfigDescriptor()
      Returns the JSP config descriptor.
      Returns:
      the JSP config descriptor
    • getMajorVersion

      int getMajorVersion()
      Returns the major version.
      Returns:
      the major version
    • getMimeType

      String getMimeType(String filename)
      Get the mime type.
      Parameters:
      filename - the filename.
      Returns:
      the mime type, or null.
    • getMinorVersion

      int getMinorVersion()
      Returns the minor version.
      Returns:
      the minor version
    • getNamedDispatcher

      RequestDispatcher getNamedDispatcher(String name)
      Get the named dispatcher.
      Parameters:
      name - the name.
      Returns:
      the request dispatcher, or null if not found.
    • getRealPath

      String getRealPath(String path)
      Returns the real path.
      Parameters:
      path - the path.
      Returns:
      the real path
    • getRequestCharacterEncoding

      String getRequestCharacterEncoding()
      Returns the default request character encoding.
      Returns:
      the default request character encoding
    • getRequestDispatcher

      RequestDispatcher getRequestDispatcher(String path)
      Get the request dispatcher.
      Parameters:
      path - the path.
      Returns:
      the request dispatcher, or null.
    • getResponseCharacterEncoding

      String getResponseCharacterEncoding()
      Returns the default response character encoding.
      Returns:
      the default response character encoding
    • getResource

      URL getResource(String path) throws MalformedURLException
      Get the resource.
      Parameters:
      path - the path.
      Returns:
      the URL, or null if not found.
      Throws:
      MalformedURLException - when the path is malformed.
    • getResourceAsStream

      InputStream getResourceAsStream(String path)
      Get the resource as a stream.
      Parameters:
      path - the path.
      Returns:
      the input stream, or null.
    • getResourcePaths

      Set<String> getResourcePaths(String path)
      Get the resource paths for the given path.
      Parameters:
      path - the path.
      Returns:
      the resource paths.
    • getServerInfo

      String getServerInfo()
      Returns the server info.
      Returns:
      the server info
    • getServlet

      @Deprecated Servlet getServlet(String name) throws ServletException
      Deprecated.
      Get the servlet.
      Parameters:
      name - the name.
      Returns:
      null
      Throws:
      ServletException - when a servlet error occurs.
    • getServletContextName

      String getServletContextName()
      Returns the servlet context name.
      Returns:
      the servlet context name
    • getServletNames

      @Deprecated Enumeration<String> getServletNames()
      Deprecated.
      Get the servlet names.
      Returns:
      an empty enumeration.
    • getServletRegistration

      ServletRegistration getServletRegistration(String servletName)
      Get the servlet registration.
      Parameters:
      servletName - the servlet name.
      Returns:
      the servlet registration, or null if not found.
    • getServletRegistrations

      Map<String,​? extends ServletRegistration> getServletRegistrations()
      Returns the servlet registrations.
      Returns:
      the servlet registrations
    • getServlets

      Deprecated.
      Get the servlets.
      Returns:
      an empty enumeration.
    • getSessionCookieConfig

      SessionCookieConfig getSessionCookieConfig()
      Returns the session cookie config.
      Returns:
      the session cookie config
    • getSessionTimeout

      int getSessionTimeout()
      Returns the default session timeout.
      Returns:
      the default session timeout
    • getVirtualServerName

      String getVirtualServerName()
      Returns the virtual server name.
      Returns:
      the virtual server name
    • log

      void log(String message)
      Log the specified message.
      Parameters:
      message - the message.
    • log

      @Deprecated void log(Exception exception, String message)
      Deprecated.
      Log the exception and message.
      Parameters:
      exception - the exception.
      message - the message.
    • log

      void log(String message, Throwable throwable)
      Log the message and throwable.
      Parameters:
      message - the message.
      throwable - the throwable.
    • removeAttribute

      void removeAttribute(String name)
      Remove the attribute.
      Parameters:
      name - the name.
    • setAttribute

      void setAttribute(String name, Object object)
      Set the attribute.
      Parameters:
      name - the name.
      object - the object value.
    • setInitParameter

      boolean setInitParameter(String name, String value)
      Set the init parameter.
      Parameters:
      name - the name.
      value - the value.
      Returns:
      true if it was set, false otherwise.
    • setRequestCharacterEncoding

      void setRequestCharacterEncoding(String requestCharacterEncoding)
      Set the default request character encoding.
      Parameters:
      requestCharacterEncoding - the default request character encoding.
    • setResponseCharacterEncoding

      void setResponseCharacterEncoding(String responseCharacterEncoding)
      Set the default response character encoding.
      Parameters:
      responseCharacterEncoding - the default response character encoding.
    • setSessionTimeout

      void setSessionTimeout(int sessionTimeout)
      Set the default session timeout.
      Parameters:
      sessionTimeout - the default session timeout.
    • setSessionTrackingModes

      void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
      Set the session tracking modes.
      Parameters:
      sessionTrackingModes - the session tracking modes.