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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `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.
    `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)`
    `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.
    `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` | `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` | `removeAttribute(String name)`
    `void` | `setAttribute(String name, Object o)`
    `void` | `setCharacterEncoding(String env)` Can only be invoked in the event phase.

    - ### 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()`

    - #### 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.

    - #### 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()`

    - #### 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.

    - #### 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–2018 Apache Software Foundation. All rights reserved.