Class ServletWebContext

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map, Context

    public class ServletWebContext
    extends WebContext

    Concrete implementation of WebContext suitable for use in Servlets and JSP pages. The abstract methods are mapped to the appropriate collections of the underlying servlet context, request, and response instances that are passed to the constructor (or the initialize method).

    Version:
    $Revision: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
    Author:
    Craig R. McClanahan
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map applicationScope
      The lazily instantiated Map of application scope attributes.
      protected javax.servlet.ServletContext context
      The ServletContext for this web application.
      private java.util.Map cookieValues
      The lazily instantiated Map of cookies.
      private java.util.Map header
      The lazily instantiated Map of header name-value combinations (immutable).
      private java.util.Map headerValues
      The lazily instantitated Map of header name-values combinations (immutable).
      private java.util.Map initParam
      The lazily instantiated Map of context initialization parameters.
      private java.util.Map param
      The lazily instantiated Map of request parameter name-value.
      private java.util.Map paramValues
      The lazily instantiated Map of request parameter name-values.
      protected javax.servlet.http.HttpServletRequest request
      The HttpServletRequest for this request.
      private java.util.Map requestScope
      The lazily instantiated Map of request scope attributes.
      protected javax.servlet.http.HttpServletResponse response
      The HttpServletResponse for this request.
      private java.util.Map sessionScope
      The lazily instantiated Map of session scope attributes.
    • Constructor Summary

      Constructors 
      Constructor Description
      ServletWebContext()
      Construct an uninitialized ServletWebContext instance.
      ServletWebContext​(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Construct a ServletWebContext instance that is initialized with the specified Servlet API objects.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map getApplicationScope()
      See the WebContext's Javadoc.
      javax.servlet.ServletContext getContext()
      Return the ServletContext for this context.
      java.util.Map getCookies()
      See the WebContext's Javadoc.
      java.util.Map getHeader()
      See the WebContext's Javadoc.
      java.util.Map getHeaderValues()
      See the WebContext's Javadoc.
      java.util.Map getInitParam()
      See the WebContext's Javadoc.
      java.util.Map getParam()
      See the WebContext's Javadoc.
      java.util.Map getParamValues()
      See the WebContext's Javadoc.
      javax.servlet.http.HttpServletRequest getRequest()
      Return the HttpServletRequest for this context.
      java.util.Map getRequestScope()
      See the WebContext's Javadoc.
      javax.servlet.http.HttpServletResponse getResponse()
      Return the HttpServletResponse for this context.
      java.util.Map getSessionScope()
      See the WebContext's Javadoc.
      void initialize​(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Initialize (or reinitialize) this ServletWebContext instance for the specified Servlet API objects.
      void release()
      Release references to allocated resources acquired in initialize() of via subsequent processing.
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, containsKey, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll, size
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, containsKey, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll, size
    • Field Detail

      • applicationScope

        private java.util.Map applicationScope

        The lazily instantiated Map of application scope attributes.

      • context

        protected javax.servlet.ServletContext context

        The ServletContext for this web application.

      • header

        private java.util.Map header

        The lazily instantiated Map of header name-value combinations (immutable).

      • headerValues

        private java.util.Map headerValues

        The lazily instantitated Map of header name-values combinations (immutable).

      • initParam

        private java.util.Map initParam

        The lazily instantiated Map of context initialization parameters.

      • cookieValues

        private java.util.Map cookieValues

        The lazily instantiated Map of cookies.

      • param

        private java.util.Map param

        The lazily instantiated Map of request parameter name-value.

      • paramValues

        private java.util.Map paramValues

        The lazily instantiated Map of request parameter name-values.

      • request

        protected javax.servlet.http.HttpServletRequest request

        The HttpServletRequest for this request.

      • requestScope

        private java.util.Map requestScope

        The lazily instantiated Map of request scope attributes.

      • response

        protected javax.servlet.http.HttpServletResponse response

        The HttpServletResponse for this request.

      • sessionScope

        private java.util.Map sessionScope

        The lazily instantiated Map of session scope attributes.

    • Constructor Detail

      • ServletWebContext

        public ServletWebContext()

        Construct an uninitialized ServletWebContext instance.

      • ServletWebContext

        public ServletWebContext​(javax.servlet.ServletContext context,
                                 javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response)

        Construct a ServletWebContext instance that is initialized with the specified Servlet API objects.

        Parameters:
        context - The ServletContext for this web application
        request - The HttpServletRequest for this request
        response - The HttpServletResponse for this request
    • Method Detail

      • getContext

        public javax.servlet.ServletContext getContext()

        Return the ServletContext for this context.

        Returns:
        The ServletContext for this context.
      • getRequest

        public javax.servlet.http.HttpServletRequest getRequest()

        Return the HttpServletRequest for this context.

        Returns:
        The HttpServletRequest for this context.
      • getResponse

        public javax.servlet.http.HttpServletResponse getResponse()

        Return the HttpServletResponse for this context.

        Returns:
        The HttpServletResponse for this context.
      • initialize

        public void initialize​(javax.servlet.ServletContext context,
                               javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)

        Initialize (or reinitialize) this ServletWebContext instance for the specified Servlet API objects.

        Parameters:
        context - The ServletContext for this web application
        request - The HttpServletRequest for this request
        response - The HttpServletResponse for this request
      • release

        public void release()

        Release references to allocated resources acquired in initialize() of via subsequent processing. After this method is called, subsequent calls to any other method than initialize() will return undefined results.

      • getHeader

        public java.util.Map getHeader()
        See the WebContext's Javadoc.
        Specified by:
        getHeader in class WebContext
        Returns:
        Header values Map.
      • getInitParam

        public java.util.Map getInitParam()
        See the WebContext's Javadoc.
        Specified by:
        getInitParam in class WebContext
        Returns:
        Initialization parameter Map.
      • getParam

        public java.util.Map getParam()
        See the WebContext's Javadoc.
        Specified by:
        getParam in class WebContext
        Returns:
        Request parameter Map.
      • getCookies

        public java.util.Map getCookies()
        See the WebContext's Javadoc.
        Specified by:
        getCookies in class WebContext
        Returns:
        Map of Cookies.
        Since:
        Chain 1.1