Package javax.servlet

Interface ServletContext

All Known Subinterfaces:
WebApplication
All Known Implementing Classes:
DefaultWebApplication

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

  • Method Details

    • addFilter

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

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

      FilterRegistration.Dynamic addFilter​(java.lang.String filterName, java.lang.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​(java.lang.String servletName, java.lang.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​(java.lang.String className)
      Add the listener.
      Parameters:
      className - the class name.
    • addListener

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

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

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

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

      ServletRegistration.Dynamic addServlet​(java.lang.String servletName, java.lang.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​(java.lang.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 java.util.EventListener> T createListener​(java.lang.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​(java.lang.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​(java.lang.String... roles)
      Declare the roles.
      Parameters:
      roles - the roles.
    • getAttribute

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

      java.util.Enumeration<java.lang.String> getAttributeNames()
      Get the attribute names.
      Returns:
      the attribute names.
    • getClassLoader

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

      ServletContext getContext​(java.lang.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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      java.lang.String getRealPath​(java.lang.String path)
      Get the real path.
      Parameters:
      path - the path.
      Returns:
      the real path.
    • getRequestCharacterEncoding

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

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

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

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

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

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

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

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

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

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

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

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

      @Deprecated java.util.Enumeration<Servlet> getServlets()
      Deprecated.
      Get the servlets.
      Returns:
      an empty enumeration.
    • getSessionCookieConfig

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

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

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

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

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

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

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

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

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

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

      void setResponseCharacterEncoding​(java.lang.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​(java.util.Set<SessionTrackingMode> sessionTrackingModes)
      Set the session tracking modes.
      Parameters:
      sessionTrackingModes - the session tracking modes.