org.apache.struts2.portlet.servlet

## Class PortletServletRequest

- java.lang.Object
- - org.apache.struts2.portlet.servlet.PortletServletRequest

- All Implemented Interfaces:
    javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

      public class PortletServletRequest
      extends Object
      implements javax.servlet.http.HttpServletRequest

  Wrapper object exposing a `PortletRequest` as a `HttpServletRequest` instance. Clients accessing this request object will in fact operate on the `PortletRequest` object wrapped by this request object.

- - ### Field Summary

    - ### Fields inherited from interface javax.servlet.http.HttpServletRequest

      `BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PortletServletRequest(javax.portlet.PortletRequest portletRequest, javax.portlet.PortletContext portletContext)`
    `PortletServletRequest(javax.portlet.PortletRequest portletRequest, javax.portlet.PortletContext portletContext, Map<String,String[]> extraParams)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `authenticate(javax.servlet.http.HttpServletResponse response)`
    `String` | `changeSessionId()`
    `javax.servlet.AsyncContext` | `getAsyncContext()`
    `Object` | `getAttribute(String name)` Gets an attribute value on the `PortletRequest`.
    `Enumeration` | `getAttributeNames()`
    `String` | `getAuthType()`
    `String` | `getCharacterEncoding()` Can only be invoked in the event phase.
    `int` | `getContentLength()` Can only be invoked in the event phase.
    `long` | `getContentLengthLong()`
    `String` | `getContentType()` Can only be invoked in the event phase.
    `String` | `getContextPath()`
    `javax.servlet.http.Cookie[]` | `getCookies()` Not allowed in a portlet.
    `long` | `getDateHeader(String name)` Not allowed in a portlet.
    `javax.servlet.DispatcherType` | `getDispatcherType()`
    `String` | `getHeader(String name)` Gets a property from the `PortletRequest`.
    `Enumeration` | `getHeaderNames()` Gets the property names from the `PortletRequest`.
    `Enumeration` | `getHeaders(String name)` Gets the values for the specified property from the `PortletRequest`.
    `javax.servlet.ServletInputStream` | `getInputStream()` Can only be invoked in the event phase.
    `int` | `getIntHeader(String name)` Not allowed in a portlet.
    `String` | `getLocalAddr()` Not allowed in a portlet.
    `Locale` | `getLocale()`
    `Enumeration` | `getLocales()`
    `String` | `getLocalName()` Not allowed in a portlet.
    `int` | `getLocalPort()` Not allowed in a portlet.
    `String` | `getMethod()`
    `String` | `getParameter(String name)`
    `Map` | `getParameterMap()`
    `Enumeration` | `getParameterNames()`
    `String[]` | `getParameterValues(String name)`
    `javax.servlet.http.Part` | `getPart(String name)`
    `Collection<javax.servlet.http.Part>` | `getParts()`
    `String` | `getPathInfo()`
    `String` | `getPathTranslated()`
    `javax.portlet.PortletRequest` | `getPortletRequest()` Get the wrapped `PortletRequest` instance.
    `String` | `getProtocol()` Not allowed in a portlet.
    `String` | `getQueryString()`
    `BufferedReader` | `getReader()` Can only be invoked in the event phase.
    `String` | `getRealPath(String path)`
    `String` | `getRemoteAddr()` Not allowed in a portlet.
    `String` | `getRemoteHost()` Not allowed in a portlet.
    `int` | `getRemotePort()` Not allowed in a portlet.
    `String` | `getRemoteUser()`
    `javax.servlet.RequestDispatcher` | `getRequestDispatcher(String path)` Get the `PortletRequestDispatcher` as a `PortletServletRequestDispatcher` instance.
    `String` | `getRequestedSessionId()`
    `String` | `getRequestURI()` Not allowed in a portlet.
    `StringBuffer` | `getRequestURL()` Not allowed in a portlet.
    `String` | `getScheme()`
    `String` | `getServerName()`
    `int` | `getServerPort()` Not allowed in a portlet.
    `javax.servlet.ServletContext` | `getServletContext()`
    `String` | `getServletPath()` A `PortletRequest` has no servlet path.
    `javax.servlet.http.HttpSession` | `getSession()` Get the `PortletSession` as a `PortletHttpSession` instance.
    `javax.servlet.http.HttpSession` | `getSession(boolean create)` Get the `PortletSession` as a `PortletHttpSession` instance.
    `Principal` | `getUserPrincipal()`
    `boolean` | `isAsyncStarted()`
    `boolean` | `isAsyncSupported()`
    `boolean` | `isRequestedSessionIdFromCookie()` Not allowed in a portlet.
    `boolean` | `isRequestedSessionIdFromUrl()` Not allowed in a portlet.
    `boolean` | `isRequestedSessionIdFromURL()` Not allowed in a portlet.
    `boolean` | `isRequestedSessionIdValid()`
    `boolean` | `isSecure()`
    `boolean` | `isUserInRole(String role)`
    `void` | `login(String username, String password)`
    `void` | `logout()`
    `void` | `removeAttribute(String name)`
    `void` | `setAttribute(String name, Object o)`
    `void` | `setCharacterEncoding(String env)` Can only be invoked in the event phase.
    `javax.servlet.AsyncContext` | `startAsync()`
    `javax.servlet.AsyncContext` | `startAsync(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse)`
    `<T extends javax.servlet.http.HttpUpgradeHandler> T` | `upgrade(Class<T> handlerClass)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PortletServletRequest

          public PortletServletRequest(javax.portlet.PortletRequest portletRequest,
                                       javax.portlet.PortletContext portletContext)

    - #### PortletServletRequest

          public PortletServletRequest(javax.portlet.PortletRequest portletRequest,
                                       javax.portlet.PortletContext portletContext,
                                       Map<String,String[]> extraParams)

  - ### Method Detail

    - #### getAuthType

          public String getAuthType()

      Specified by:
        `getAuthType` in interface `javax.servlet.http.HttpServletRequest`

    - #### getContextPath

          public String getContextPath()

      Specified by:
        `getContextPath` in interface `javax.servlet.http.HttpServletRequest`

    - #### getCookies

          public javax.servlet.http.Cookie[] getCookies()

      Not allowed in a portlet.
      Specified by:
        `getCookies` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getDateHeader

          public long getDateHeader(String name)

      Not allowed in a portlet.
      Specified by:
        `getDateHeader` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getHeader

          public String getHeader(String name)

      Gets a property from the `PortletRequest`. Note that a `PortletRequest` is not guaranteed to map properties to headers.
      Specified by:
        `getHeader` in interface `javax.servlet.http.HttpServletRequest`
      See Also:
        `PortletRequest.getProperty(String)`, `HttpServletRequest.getHeader(java.lang.String)`

    - #### getHeaderNames

          public Enumeration getHeaderNames()

      Gets the property names from the `PortletRequest`. Note that a `PortletRequest` is not guaranteed to map properties to headers.
      Specified by:
        `getHeaderNames` in interface `javax.servlet.http.HttpServletRequest`
      See Also:
        `PortletRequest.getPropertyNames()`, `HttpServletRequest.getHeaderNames()`

    - #### getHeaders

          public Enumeration getHeaders(String name)

      Gets the values for the specified property from the `PortletRequest`. Note that a `PortletRequest` is not guaranteed to map properties to headers.
      Specified by:
        `getHeaders` in interface `javax.servlet.http.HttpServletRequest`
      See Also:
        `PortletRequest.getProperties(String)`, `HttpServletRequest.getHeaders(String)`

    - #### getIntHeader

          public int getIntHeader(String name)

      Not allowed in a portlet.
      Specified by:
        `getIntHeader` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getMethod

          public String getMethod()

      Specified by:
        `getMethod` in interface `javax.servlet.http.HttpServletRequest`

    - #### getPathInfo

          public String getPathInfo()

      Specified by:
        `getPathInfo` in interface `javax.servlet.http.HttpServletRequest`

    - #### getPathTranslated

          public String getPathTranslated()

      Specified by:
        `getPathTranslated` in interface `javax.servlet.http.HttpServletRequest`

    - #### getQueryString

          public String getQueryString()

      Specified by:
        `getQueryString` in interface `javax.servlet.http.HttpServletRequest`

    - #### getRemoteUser

          public String getRemoteUser()

      Specified by:
        `getRemoteUser` in interface `javax.servlet.http.HttpServletRequest`

    - #### getRequestURI

          public String getRequestURI()

      Not allowed in a portlet.
      Specified by:
        `getRequestURI` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getRequestURL

          public StringBuffer getRequestURL()

      Not allowed in a portlet.
      Specified by:
        `getRequestURL` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getRequestedSessionId

          public String getRequestedSessionId()

      Specified by:
        `getRequestedSessionId` in interface `javax.servlet.http.HttpServletRequest`

    - #### getServletPath

          public String getServletPath()

      A `PortletRequest` has no servlet path. But for compatibility with Struts 2 components and interceptors, the action parameter on the request is mapped to the servlet path.
      Specified by:
        `getServletPath` in interface `javax.servlet.http.HttpServletRequest`
      See Also:
        `HttpServletRequest.getServletPath()`

    - #### getSession

          public javax.servlet.http.HttpSession getSession()

      Get the `PortletSession` as a `PortletHttpSession` instance.
      Specified by:
        `getSession` in interface `javax.servlet.http.HttpServletRequest`
      See Also:
        `HttpServletRequest.getSession()`

    - #### changeSessionId

          public String changeSessionId()

      Specified by:
        `changeSessionId` in interface `javax.servlet.http.HttpServletRequest`

    - #### getSession

          public javax.servlet.http.HttpSession getSession(boolean create)

      Get the `PortletSession` as a `PortletHttpSession` instance.
      Specified by:
        `getSession` in interface `javax.servlet.http.HttpServletRequest`
      See Also:
        `HttpServletRequest.getSession(boolean)`

    - #### getUserPrincipal

          public Principal getUserPrincipal()

      Specified by:
        `getUserPrincipal` in interface `javax.servlet.http.HttpServletRequest`

    - #### isRequestedSessionIdFromCookie

          public boolean isRequestedSessionIdFromCookie()

      Not allowed in a portlet.
      Specified by:
        `isRequestedSessionIdFromCookie` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### isRequestedSessionIdFromURL

          public boolean isRequestedSessionIdFromURL()

      Not allowed in a portlet.
      Specified by:
        `isRequestedSessionIdFromURL` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### isRequestedSessionIdFromUrl

          public boolean isRequestedSessionIdFromUrl()

      Not allowed in a portlet.
      Specified by:
        `isRequestedSessionIdFromUrl` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### authenticate

          public boolean authenticate(javax.servlet.http.HttpServletResponse response)
                               throws IOException,
                                      javax.servlet.ServletException

      Specified by:
        `authenticate` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IOException`
        `javax.servlet.ServletException`

    - #### login

          public void login(String username,
                            String password)
                     throws javax.servlet.ServletException

      Specified by:
        `login` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `javax.servlet.ServletException`

    - #### logout

          public void logout()
                      throws javax.servlet.ServletException

      Specified by:
        `logout` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `javax.servlet.ServletException`

    - #### getParts

          public Collection<javax.servlet.http.Part> getParts()
                                                       throws IOException,
                                                              javax.servlet.ServletException

      Specified by:
        `getParts` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IOException`
        `javax.servlet.ServletException`

    - #### getPart

          public javax.servlet.http.Part getPart(String name)
                                          throws IOException,
                                                 javax.servlet.ServletException

      Specified by:
        `getPart` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IOException`
        `javax.servlet.ServletException`

    - #### upgrade

          public <T extends javax.servlet.http.HttpUpgradeHandler> T upgrade(Class<T> handlerClass)
                                                                      throws IOException,
                                                                             javax.servlet.ServletException

      Specified by:
        `upgrade` in interface `javax.servlet.http.HttpServletRequest`
      Throws:
        `IOException`
        `javax.servlet.ServletException`

    - #### isRequestedSessionIdValid

          public boolean isRequestedSessionIdValid()

      Specified by:
        `isRequestedSessionIdValid` in interface `javax.servlet.http.HttpServletRequest`

    - #### isUserInRole

          public boolean isUserInRole(String role)

      Specified by:
        `isUserInRole` in interface `javax.servlet.http.HttpServletRequest`

    - #### getAttribute

          public Object getAttribute(String name)

      Gets an attribute value on the `PortletRequest`. If the attribute name is `javax.servlet.include.servlet_path`, it returns the same as `getServletPath()`
      Specified by:
        `getAttribute` in interface `javax.servlet.ServletRequest`
      See Also:
        `ServletRequest.getAttribute(java.lang.String)`

    - #### getAttributeNames

          public Enumeration getAttributeNames()

      Specified by:
        `getAttributeNames` in interface `javax.servlet.ServletRequest`

    - #### getCharacterEncoding

          public String getCharacterEncoding()

      Can only be invoked in the event phase.
      Specified by:
        `getCharacterEncoding` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - If the portlet is not in the event phase.
      See Also:
        `ServletRequest.getCharacterEncoding()`

    - #### getContentLength

          public int getContentLength()

      Can only be invoked in the event phase.
      Specified by:
        `getContentLength` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - If the portlet is not in the event phase.
      See Also:
        `ServletRequest.getContentLength()`

    - #### getContentLengthLong

          public long getContentLengthLong()

      Specified by:
        `getContentLengthLong` in interface `javax.servlet.ServletRequest`

    - #### getContentType

          public String getContentType()

      Can only be invoked in the event phase.
      Specified by:
        `getContentType` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - If the portlet is not in the event phase.
      See Also:
        `ServletRequest.getContentType()`

    - #### getInputStream

          public javax.servlet.ServletInputStream getInputStream()
                                                          throws IOException

      Can only be invoked in the event phase. When invoked in the event phase, it will wrap the portlet's `InputStream` as a `PortletServletInputStream`.
      Specified by:
        `getInputStream` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - If the portlet is not in the event phase.
        `IOException`
      See Also:
        `ServletRequest.getInputStream()`

    - #### getLocalAddr

          public String getLocalAddr()

      Not allowed in a portlet.
      Specified by:
        `getLocalAddr` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getLocalName

          public String getLocalName()

      Not allowed in a portlet.
      Specified by:
        `getLocalName` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getLocalPort

          public int getLocalPort()

      Not allowed in a portlet.
      Specified by:
        `getLocalPort` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getServletContext

          public javax.servlet.ServletContext getServletContext()

      Specified by:
        `getServletContext` in interface `javax.servlet.ServletRequest`

    - #### startAsync

          public javax.servlet.AsyncContext startAsync()
                                                throws IllegalStateException

      Specified by:
        `startAsync` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException`

    - #### startAsync

          public javax.servlet.AsyncContext startAsync(javax.servlet.ServletRequest servletRequest,
                                                       javax.servlet.ServletResponse servletResponse)
                                                throws IllegalStateException

      Specified by:
        `startAsync` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException`

    - #### isAsyncStarted

          public boolean isAsyncStarted()

      Specified by:
        `isAsyncStarted` in interface `javax.servlet.ServletRequest`

    - #### isAsyncSupported

          public boolean isAsyncSupported()

      Specified by:
        `isAsyncSupported` in interface `javax.servlet.ServletRequest`

    - #### getAsyncContext

          public javax.servlet.AsyncContext getAsyncContext()

      Specified by:
        `getAsyncContext` in interface `javax.servlet.ServletRequest`

    - #### getDispatcherType

          public javax.servlet.DispatcherType getDispatcherType()

      Specified by:
        `getDispatcherType` in interface `javax.servlet.ServletRequest`

    - #### getLocale

          public Locale getLocale()

      Specified by:
        `getLocale` in interface `javax.servlet.ServletRequest`

    - #### getLocales

          public Enumeration getLocales()

      Specified by:
        `getLocales` in interface `javax.servlet.ServletRequest`

    - #### getParameter

          public String getParameter(String name)

      Specified by:
        `getParameter` in interface `javax.servlet.ServletRequest`

    - #### getParameterMap

          public Map getParameterMap()

      Specified by:
        `getParameterMap` in interface `javax.servlet.ServletRequest`

    - #### getParameterNames

          public Enumeration getParameterNames()

      Specified by:
        `getParameterNames` in interface `javax.servlet.ServletRequest`

    - #### getParameterValues

          public String[] getParameterValues(String name)

      Specified by:
        `getParameterValues` in interface `javax.servlet.ServletRequest`

    - #### getProtocol

          public String getProtocol()

      Not allowed in a portlet.
      Specified by:
        `getProtocol` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getReader

          public BufferedReader getReader()
                                   throws IOException

      Can only be invoked in the event phase.
      Specified by:
        `getReader` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - If the portlet is not in the event phase.
        `IOException`
      See Also:
        `ServletRequest.getReader()`

    - #### getRealPath

          public String getRealPath(String path)

      Specified by:
        `getRealPath` in interface `javax.servlet.ServletRequest`

    - #### getRemoteAddr

          public String getRemoteAddr()

      Not allowed in a portlet.
      Specified by:
        `getRemoteAddr` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getRemoteHost

          public String getRemoteHost()

      Not allowed in a portlet.
      Specified by:
        `getRemoteHost` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getRemotePort

          public int getRemotePort()

      Not allowed in a portlet.
      Specified by:
        `getRemotePort` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### getRequestDispatcher

          public javax.servlet.RequestDispatcher getRequestDispatcher(String path)

      Get the `PortletRequestDispatcher` as a `PortletServletRequestDispatcher` instance.
      Specified by:
        `getRequestDispatcher` in interface `javax.servlet.ServletRequest`
      See Also:
        `ServletRequest.getRequestDispatcher(java.lang.String)`

    - #### getScheme

          public String getScheme()

      Specified by:
        `getScheme` in interface `javax.servlet.ServletRequest`

    - #### getServerName

          public String getServerName()

      Specified by:
        `getServerName` in interface `javax.servlet.ServletRequest`

    - #### getServerPort

          public int getServerPort()

      Not allowed in a portlet.
      Specified by:
        `getServerPort` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - Not allowed in a portlet.

    - #### isSecure

          public boolean isSecure()

      Specified by:
        `isSecure` in interface `javax.servlet.ServletRequest`

    - #### removeAttribute

          public void removeAttribute(String name)

      Specified by:
        `removeAttribute` in interface `javax.servlet.ServletRequest`

    - #### setAttribute

          public void setAttribute(String name,
                                   Object o)

      Specified by:
        `setAttribute` in interface `javax.servlet.ServletRequest`

    - #### setCharacterEncoding

          public void setCharacterEncoding(String env)
                                    throws UnsupportedEncodingException

      Can only be invoked in the event phase.
      Specified by:
        `setCharacterEncoding` in interface `javax.servlet.ServletRequest`
      Throws:
        `IllegalStateException` - If the portlet is not in the event phase.
        `UnsupportedEncodingException`
      See Also:
        `ServletRequest.setCharacterEncoding(String)`

    - #### getPortletRequest

          public javax.portlet.PortletRequest getPortletRequest()

      Get the wrapped `PortletRequest` instance.
      Returns:
        The wrapped `PortletRequest` instance.

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.