org.apache.struts2.portlet.servlet
Class PortletServletRequest

java.lang.Object
  extended by org.apache.struts2.portlet.servlet.PortletServletRequest
All Implemented Interfaces:
HttpServletRequest, ServletRequest, PortletActionConstants

public class PortletServletRequest
extends Object
implements HttpServletRequest, PortletActionConstants

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
private  javax.portlet.PortletContext portletContext
           
private  javax.portlet.PortletRequest portletRequest
           
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Fields inherited from interface org.apache.struts2.portlet.PortletActionConstants
ACTION_PARAM, ACTION_RESET, DEFAULT_ACTION_FOR_MODE, DEFAULT_ACTION_NAME, DEFAULT_DISPATCHER_SERVLET_NAME, ERROR_ACTION, EVENT_ACTION, EVENT_PHASE, MODE_NAMESPACE_MAP, MODE_PARAM, PHASE, PORTLET_CONFIG, PORTLET_NAMESPACE, RENDER_DIRECT_LOCATION, RENDER_PHASE, REQUEST, RESPONSE, STACK_FROM_EVENT_PHASE
 
Constructor Summary
PortletServletRequest(javax.portlet.PortletRequest portletRequest, javax.portlet.PortletContext portletContext)
           
 
Method Summary
 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()
           
 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.
 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()
           
 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.
 HttpSession getSession()
          Get the PortletSession as a PortletHttpSession instance.
 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
 

Field Detail

portletRequest

private javax.portlet.PortletRequest portletRequest

portletContext

private javax.portlet.PortletContext portletContext
Constructor Detail

PortletServletRequest

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

getAuthType

public String getAuthType()
Specified by:
getAuthType in interface HttpServletRequest

getContextPath

public String getContextPath()
Specified by:
getContextPath in interface HttpServletRequest

getCookies

public Cookie[] getCookies()
Not allowed in a portlet.

Specified by:
getCookies in interface HttpServletRequest
Throws:
IllegalStateException - Not allowed in a portlet.

getDateHeader

public long getDateHeader(String name)
Not allowed in a portlet.

Specified by:
getDateHeader in interface 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 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 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 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 HttpServletRequest
Throws:
IllegalStateException - Not allowed in a portlet.

getMethod

public String getMethod()
Specified by:
getMethod in interface HttpServletRequest

getPathInfo

public String getPathInfo()
Specified by:
getPathInfo in interface HttpServletRequest

getPathTranslated

public String getPathTranslated()
Specified by:
getPathTranslated in interface HttpServletRequest

getQueryString

public String getQueryString()
Specified by:
getQueryString in interface HttpServletRequest

getRemoteUser

public String getRemoteUser()
Specified by:
getRemoteUser in interface HttpServletRequest

getRequestURI

public String getRequestURI()
Not allowed in a portlet.

Specified by:
getRequestURI in interface HttpServletRequest
Throws:
IllegalStateException - Not allowed in a portlet.

getRequestURL

public StringBuffer getRequestURL()
Not allowed in a portlet.

Specified by:
getRequestURL in interface HttpServletRequest
Throws:
IllegalStateException - Not allowed in a portlet.

getRequestedSessionId

public String getRequestedSessionId()
Specified by:
getRequestedSessionId in interface 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 HttpServletRequest
See Also:
HttpServletRequest.getServletPath()

getSession

public HttpSession getSession()
Get the PortletSession as a PortletHttpSession instance.

Specified by:
getSession in interface HttpServletRequest
See Also:
HttpServletRequest.getSession()

getSession

public HttpSession getSession(boolean create)
Get the PortletSession as a PortletHttpSession instance.

Specified by:
getSession in interface HttpServletRequest
See Also:
HttpServletRequest.getSession(boolean)

getUserPrincipal

public Principal getUserPrincipal()
Specified by:
getUserPrincipal in interface HttpServletRequest

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Not allowed in a portlet.

Specified by:
isRequestedSessionIdFromCookie in interface HttpServletRequest
Throws:
IllegalStateException - Not allowed in a portlet.

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()
Not allowed in a portlet.

Specified by:
isRequestedSessionIdFromURL in interface HttpServletRequest
Throws:
IllegalStateException - Not allowed in a portlet.

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()
Not allowed in a portlet.

Specified by:
isRequestedSessionIdFromUrl in interface HttpServletRequest
Throws:
IllegalStateException - Not allowed in a portlet.

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Specified by:
isRequestedSessionIdValid in interface HttpServletRequest

isUserInRole

public boolean isUserInRole(String role)
Specified by:
isUserInRole in interface 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 ServletRequest
See Also:
ServletRequest.getAttribute(java.lang.String)

getAttributeNames

public Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface ServletRequest

getCharacterEncoding

public String getCharacterEncoding()
Can only be invoked in the event phase.

Specified by:
getCharacterEncoding in interface 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 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 ServletRequest
Throws:
IllegalStateException - If the portlet is not in the event phase.
See Also:
ServletRequest.getContentType()

getInputStream

public 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 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 ServletRequest
Throws:
IllegalStateException - Not allowed in a portlet.

getLocalName

public String getLocalName()
Not allowed in a portlet.

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

getLocalPort

public int getLocalPort()
Not allowed in a portlet.

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

getLocale

public Locale getLocale()
Specified by:
getLocale in interface ServletRequest

getLocales

public Enumeration getLocales()
Specified by:
getLocales in interface ServletRequest

getParameter

public String getParameter(String name)
Specified by:
getParameter in interface ServletRequest

getParameterMap

public Map getParameterMap()
Specified by:
getParameterMap in interface ServletRequest

getParameterNames

public Enumeration getParameterNames()
Specified by:
getParameterNames in interface ServletRequest

getParameterValues

public String[] getParameterValues(String name)
Specified by:
getParameterValues in interface ServletRequest

getProtocol

public String getProtocol()
Not allowed in a portlet.

Specified by:
getProtocol in interface 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 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 ServletRequest

getRemoteAddr

public String getRemoteAddr()
Not allowed in a portlet.

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

getRemoteHost

public String getRemoteHost()
Not allowed in a portlet.

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

getRemotePort

public int getRemotePort()
Not allowed in a portlet.

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

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)
Get the PortletRequestDispatcher as a PortletServletRequestDispatcher instance.

Specified by:
getRequestDispatcher in interface ServletRequest
See Also:
ServletRequest.getRequestDispatcher(java.lang.String)

getScheme

public String getScheme()
Specified by:
getScheme in interface ServletRequest

getServerName

public String getServerName()
Specified by:
getServerName in interface ServletRequest

getServerPort

public int getServerPort()
Not allowed in a portlet.

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

isSecure

public boolean isSecure()
Specified by:
isSecure in interface ServletRequest

removeAttribute

public void removeAttribute(String name)
Specified by:
removeAttribute in interface ServletRequest

setAttribute

public void setAttribute(String name,
                         Object o)
Specified by:
setAttribute in interface ServletRequest

setCharacterEncoding

public void setCharacterEncoding(String env)
                          throws UnsupportedEncodingException
Can only be invoked in the event phase.

Specified by:
setCharacterEncoding in interface 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-2008 Apache Software Foundation. All Rights Reserved.