Package javax.servlet

Interface ServletContext

  • All Known Subinterfaces:
    WebApplication
    All Known Implementing Classes:
    DefaultWebApplication

    public interface ServletContext
    The servlet context API.
    Author:
    Manfred Riem (mriem@manorrock.com)
    • Method Detail

      • 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()
        Get the attribute names.
        Returns:
        the attribute names.
      • getClassLoader

        ClassLoader getClassLoader()
        Get 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()
        Get the context path.
        Returns:
        the context path.
      • getDefaultSessionTrackingModes

        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

        Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
        Get 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()
        Get 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()
        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

        String getMimeType​(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​(String name)
        Get the named dispatcher.
        Parameters:
        name - the name.
        Returns:
        the request dispatcher, or null if not found.
      • getRealPath

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

        String getRequestCharacterEncoding()
        Get 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()
        Get the default response character encoding.
        Returns:
        the default response character encoding.
      • 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()
        Get the server info.
        Returns:
        the server info.
      • getServletContextName

        String getServletContextName()
        Get the servlet context name.
        Returns:
        the servlet context name.
      • 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()
        Get the servlet registrations.
        Returns:
        the servlet registrations.
      • 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

        String getVirtualServerName()
        Get 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.