JavaScript is disabled on your browser.
javax.servlet

Class ServletRequestWrapper

  • All Implemented Interfaces:
    ServletRequest
    Direct Known Subclasses:
    HttpServletRequestWrapper


    public class ServletRequestWrapper
    extends java.lang.Object
    implements ServletRequest 
    This class provides an adapter that makes it easy to wrap a request The default behavior of this class is to pass all method calls in the ServletRequest interface through to the underlying request object
    Since:
    2.3
    • Constructor Summary

      Constructors
      Constructor and Description
      ServletRequestWrapper (ServletRequest wrappedRequest)
      Create a new wrapper which will wrap the given request the default behaviour is to pass all method calls in the ServletRequest interface to the
    • Method Summary

      Methods
      Modifier and Type Method and Description
      AsyncContext getAsyncContext ()
      Calls the underlying request object's method
      java.lang.Object getAttribute (java.lang.String name)
      Calls the wrapped request object's method
      java.util.Enumeration getAttributeNames ()
      Calls the wrapped request object's method
      java.lang.String getCharacterEncoding ()
      Calls the wrapped request object's method
      int getContentLength ()
      Calls the wrapped request object's method
      java.lang.String getContentType ()
      Calls the wrapped request object's method
      DispatcherType getDispatcherType ()
      Calls the underlying request object's method
      ServletInputStream getInputStream ()
      Calls the underlying request object's method
      java.lang.String getLocalAddr ()
      Calls the underlying request object's method
      java.util.Locale getLocale ()
      Calls the underlying request object's method
      java.util.Enumeration getLocales ()
      Calls the underlying request object's method
      java.lang.String getLocalName ()
      Calls the underlying request object's method
      int getLocalPort ()
      Calls the underlying request object's method
      java.lang.String getParameter (java.lang.String name)
      Calls the underlying request object's method
      java.util.Map getParameterMap ()
      Calls the underlying request object's method
      java.util.Enumeration getParameterNames ()
      Calls the underlying request object's method
      java.lang.String[] getParameterValues (java.lang.String name)
      Calls the underlying request object's method
      java.lang.String getProtocol ()
      Calls the underlying request object's method
      java.io.BufferedReader getReader ()
      Calls the underlying request object's method
      java.lang.String getRealPath (java.lang.String path)
      Deprecated.
      Should use getRealPath from the current ServletContext.
      java.lang.String getRemoteAddr ()
      Calls the underlying request object's method
      java.lang.String getRemoteHost ()
      Calls the underlying request object's method
      int getRemotePort ()
      Calls the underlying request object's method
      ServletRequest getRequest ()
      Get the request wrapped by this object
      RequestDispatcher getRequestDispatcher (java.lang.String path)
      Calls the underlying request object's method
      java.lang.String getScheme ()
      Calls the underlying request object's method
      java.lang.String getServerName ()
      Calls the underlying request object's method
      int getServerPort ()
      Calls the underlying request object's method
      ServletContext getServletContext ()
      Calls the underlying request object's method
      boolean isAsyncStarted ()
      Calls the underlying request object's method
      boolean isAsyncSupported ()
      Calls the underlying request object's method
      boolean isSecure ()
      Calls the underlying request object's method
      boolean isWrapperFor (java.lang.Class wrappedType)
      Indicates if this wrapper wraps a request of the specified class.
      boolean isWrapperFor (ServletRequest wrapped)
      Indicates if this wrapper wraps the specified request.
      void removeAttribute (java.lang.String name)
      Calls the underlying request object's method
      void setAttribute (java.lang.String name, java.lang.Object value)
      Calls the underlying request object's method
      void setCharacterEncoding (java.lang.String enc)
      Calls the wrapped request object's method
      void setRequest (ServletRequest wrappedRequest)
      Sets a new wrapper
      AsyncContext startAsync ()
      Calls the underlying request object's method
      AsyncContext startAsync (ServletRequest request, ServletResponse response)
      Calls the underlying request object's method
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ServletRequestWrapper

        public ServletRequestWrapper(ServletRequest wrappedRequest)
        Create a new wrapper which will wrap the given request the default behaviour is to pass all method calls in the ServletRequest interface to the
        Parameters:
        wrappedRequest - the request that will be wrapped by this object
        Throws:
        java.lang.IllegalArgumentException - if wrappedRequest is null
    • Method Detail

      • getRequest

        public ServletRequest getRequest()
        Get the request wrapped by this object
        Returns:
        the wrapped request object
      • setRequest

        public void setRequest(ServletRequest wrappedRequest)
        Sets a new wrapper
        Parameters:
        wrappedRequest - the request that will be wrapped by this object
        Throws:
        java.lang.IllegalArgumentException - if wrappedRequest is null
      • getAttribute

        public java.lang.Object getAttribute(java.lang.String name)
        Calls the wrapped request object's method
        Specified by:
        getAttribute in interface ServletRequest
        Parameters:
        name - the attribute name
        Returns:
        The value of the attribute, null if not found.
      • getAttributeNames

        public java.util.Enumeration getAttributeNames()
        Calls the wrapped request object's method
        Specified by:
        getAttributeNames in interface ServletRequest
        Returns:
        The Enumeration of all attribute names set in this request.
      • getCharacterEncoding

        public java.lang.String getCharacterEncoding()
        Calls the wrapped request object's method
        Specified by:
        getCharacterEncoding in interface ServletRequest
        Returns:
        Character encoding or null if the encoding is unavailable
      • setCharacterEncoding

        public void setCharacterEncoding(java.lang.String enc)
         throws java.io.UnsupportedEncodingException
        Calls the wrapped request object's method
        Specified by:
        setCharacterEncoding in interface ServletRequest
        Parameters:
        enc - a String containing the name of the character encoding
        Throws:
        java.io.UnsupportedEncodingException - if the provided name is not a valid encoding scheme
      • getContentLength

        public int getContentLength()
        Calls the wrapped request object's method
        Specified by:
        getContentLength in interface ServletRequest
        Returns:
        the number of bytes in the request or -1 if not known
      • getContentType

        public java.lang.String getContentType()
        Calls the wrapped request object's method
        Specified by:
        getContentType in interface ServletRequest
        Returns:
        a String containing the mime type of the request or null if not known
      • getParameter

        public java.lang.String getParameter(java.lang.String name)
        Calls the underlying request object's method
        Specified by:
        getParameter in interface ServletRequest
        Parameters:
        name - the name of the parameter whose value we want
        Returns:
        the (first) value of the parameter or null if not present
      • getParameterMap

        public java.util.Map getParameterMap()
        Calls the underlying request object's method
        Specified by:
        getParameterMap in interface ServletRequest
        Returns:
        java.util.Map containing key value pairs of the request parameters, where the key is a String containing the parameter name, and the value is an array of Strings containing the parameter values
      • getParameterNames

        public java.util.Enumeration getParameterNames()
        Calls the underlying request object's method
        Specified by:
        getParameterNames in interface ServletRequest
        Returns:
        an enumeration containing all parameter names
      • getParameterValues

        public java.lang.String[] getParameterValues(java.lang.String name)
        Calls the underlying request object's method
        Specified by:
        getParameterValues in interface ServletRequest
        Parameters:
        name - the parameter name
        Returns:
        the array containing all the values or null if not present
      • getProtocol

        public java.lang.String getProtocol()
        Calls the underlying request object's method
        Specified by:
        getProtocol in interface ServletRequest
        Returns:
        A string containing the protocol name
      • getScheme

        public java.lang.String getScheme()
        Calls the underlying request object's method
        Specified by:
        getScheme in interface ServletRequest
        Returns:
        A String containing the scheme
      • getServerName

        public java.lang.String getServerName()
        Calls the underlying request object's method
        Specified by:
        getServerName in interface ServletRequest
        Returns:
        The name of the server.
      • getServerPort

        public int getServerPort()
        Calls the underlying request object's method
        Specified by:
        getServerPort in interface ServletRequest
        Returns:
        the portnumber
      • getReader

        public java.io.BufferedReader getReader()
         throws java.io.IOException
        Calls the underlying request object's method
        Specified by:
        getReader in interface ServletRequest
        Returns:
        The created BufferedReader
        Throws:
        java.io.IOException
        java.io.UnsupportedEncodingException
        java.lang.IllegalStateException
        See Also:
        ServletRequest.getInputStream()
      • getRemoteAddr

        public java.lang.String getRemoteAddr()
        Calls the underlying request object's method
        Specified by:
        getRemoteAddr in interface ServletRequest
        Returns:
        the client's ip address
      • getRemoteHost

        public java.lang.String getRemoteHost()
        Calls the underlying request object's method
        Specified by:
        getRemoteHost in interface ServletRequest
        Returns:
        the client's hostname
      • removeAttribute

        public void removeAttribute(java.lang.String name)
        Calls the underlying request object's method
        Specified by:
        removeAttribute in interface ServletRequest
        Parameters:
        name - the name of the attribute to be removed
      • getLocale

        public java.util.Locale getLocale()
        Calls the underlying request object's method
        Specified by:
        getLocale in interface ServletRequest
        Returns:
        the international locale of the request
      • getLocales

        public java.util.Enumeration getLocales()
        Calls the underlying request object's method
        Specified by:
        getLocales in interface ServletRequest
      • isSecure

        public boolean isSecure()
        Calls the underlying request object's method
        Specified by:
        isSecure in interface ServletRequest
      • getRequestDispatcher

        public RequestDispatcher getRequestDispatcher(java.lang.String path)
        Calls the underlying request object's method
        Specified by:
        getRequestDispatcher in interface ServletRequest
        Parameters:
        path - if relative it will be resolved
        Returns:
        the means if dispatching to the path
      • getRealPath

        public java.lang.String getRealPath(java.lang.String path)
        Deprecated. Should use getRealPath from the current ServletContext.
        Calls the underlying request object's method
        Specified by:
        getRealPath in interface ServletRequest
        Parameters:
        path - the path which requires translating
        Returns:
        the translated path
        See Also:
        ServletContext.getRealPath(java.lang.String)
      • getRemotePort

        public int getRemotePort()
        Calls the underlying request object's method
        Specified by:
        getRemotePort in interface ServletRequest
        Since:
        2.4
      • getLocalName

        public java.lang.String getLocalName()
         throws java.io.IOException
        Calls the underlying request object's method
        Specified by:
        getLocalName in interface ServletRequest
        Throws:
        java.io.IOException
        Since:
        2.4
      • getLocalAddr

        public java.lang.String getLocalAddr()
         throws java.io.IOException
        Calls the underlying request object's method
        Specified by:
        getLocalAddr in interface ServletRequest
        Throws:
        java.io.IOException
        Since:
        2.4
      • getLocalPort

        public int getLocalPort()
         throws java.io.IOException
        Calls the underlying request object's method
        Specified by:
        getLocalPort in interface ServletRequest
        Throws:
        java.io.IOException
        Since:
        2.4
      • startAsync

        public AsyncContext startAsync()
         throws java.lang.IllegalStateException
        Calls the underlying request object's method
        Specified by:
        startAsync in interface ServletRequest
        Returns:
        the context for the asynchronous operation
        Throws:
        java.lang.IllegalStateException
        Since:
        3.0
      • startAsync

        public AsyncContext startAsync(ServletRequest request,
         ServletResponse response)
         throws java.lang.IllegalStateException
        Calls the underlying request object's method
        Specified by:
        startAsync in interface ServletRequest
        Returns:
        the context for the asynchronous operation
        Throws:
        java.lang.IllegalStateException
        Since:
        3.0
      • isAsyncStarted

        public boolean isAsyncStarted()
        Calls the underlying request object's method
        Specified by:
        isAsyncStarted in interface ServletRequest
        Since:
        3.0
      • isAsyncSupported

        public boolean isAsyncSupported()
        Calls the underlying request object's method
        Specified by:
        isAsyncSupported in interface ServletRequest
        Since:
        3.0
      • isWrapperFor

        public boolean isWrapperFor(ServletRequest wrapped)
        Indicates if this wrapper wraps the specified request.
        Since:
        3.0
      • isWrapperFor

        public boolean isWrapperFor(java.lang.Class wrappedType)
        Indicates if this wrapper wraps a request of the specified class.
        Since:
        3.0

AltStyle によって変換されたページ (->オリジナル) /