public class PortletRequestContext extends Object implements RequestContext
PortletRequest
/ PortletResponse
abstraction needed for reverse proxy processing.Constructor and Description |
---|
PortletRequestContext(javax.portlet.PortletRequest request,
javax.portlet.PortletResponse response)
Constructs a
PortletRequestContext with given portlet request and portlet response. |
Modifier and Type | Method and Description |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response.
|
Object |
getAttribute(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
|
List<javax.servlet.http.Cookie> |
getCookies() |
String |
getHeader(String name)
Returns the value of the specified request header as a String.
|
Enumeration |
getHeaderNames()
Returns an enumeration of all the header names this request contains.
|
Enumeration |
getHeaders(String name)
Returns all the values of the specified request header as an Enumeration of String objects.
|
InputStream |
getInputStream()
Retrieves a
java.io.InputStream of the body of the request as binary data. |
String |
getMethod()
Returns the name of the HTTP method with which this request was made,
for example, GET, POST, or PUT.
|
String |
getPathInfo()
Returns any extra path information associated with the URL the client sent
when it made this request.
|
javax.portlet.PortletRequest |
getPortletRequest()
Returns the underlying portlet request.
|
javax.portlet.PortletResponse |
getPortletResponse()
Returns the underlying portlet response.
|
String |
getQueryString()
Returns the query string that is contained in the request URL after the path.
|
String |
getRequestBasePath()
Returns the base relative path of the request before the request path info.
|
String |
getScheme()
Returns the scheme of the request URI.
|
String |
getServerName()
Returns the host name of the server to which the request was sent.
|
int |
getServerPort()
Returns the port number to which the request was sent.
|
Sink |
getSink()
Returns the
Sink instance used in the current reverse proxy processing. |
int |
getStatus() |
boolean |
isSecure()
Returns a boolean indicating whether this request was made using a secure channel,
such as HTTPS.
|
void |
sendRedirect(String location)
Sends a temporary redirect response to the client using the specified redirect location URL.
|
void |
setHeader(String name,
String value)
Sets a response header with the given name and value.
|
void |
setIntHeader(String name,
int value)
Sets a response header with the given name and integer value.
|
void |
setStatus(int sc)
Sets the status code for this response.
|
public PortletRequestContext(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response)
PortletRequestContext
with given portlet request and portlet response.request
- response
- public javax.portlet.PortletRequest getPortletRequest()
public javax.portlet.PortletResponse getPortletResponse()
public boolean isSecure()
isSecure
in interface RequestContext
javax.servlet.ServletRequest#isSecure()}.
,
javax.portlet.PortletRequest#isSecure()}.
public String getScheme()
getScheme
in interface RequestContext
javax.servlet.ServletRequest#getScheme()}
,
javax.portlet.PortletRequest#getScheme()}.
public String getServerName()
getServerName
in interface RequestContext
javax.servlet.ServletRequest#getServerName()}
,
javax.portlet.PortletRequest#getServerName()}.
public int getServerPort()
getServerPort
in interface RequestContext
javax.servlet.ServletRequest#getServerPort()}
,
javax.portlet.PortletRequest#getServerPort()}.
public String getMethod()
getMethod
in interface RequestContext
javax.servlet.http.HttpServletRequest#getMethod()}
,
javax.portlet.ClientDataRequest#getMethod()}
public String getRequestBasePath()
Typically, in servlet runtime, it is either the concatenation of the request context path and the servlet path, or the concatenation of the request context path and the servlet filter mapping path prefix.
For example, in servlet runtime, if the context path is '/webcontent2', the servlet path is '/rproxy' and the path info is '/a/b/c.html', then this method may return the concatenation of the context path and servlet path, '/webcontent2/rproxy'.
Or, if a servlet filter used for reverse proxy in servlet runtime, and if the context path is '/webcontent2', the servlet filter mapping path is '/rproxy/*' and the remaining path info is '/a/b/c.html', then this method may return the concatenation of the context path and filter mapping path prefix, '/webcontent2/rproxy'.
Note: Portlet runtime doesn't give a request path info unlike servlet runtime. So, an implementation for that kind of runtime may return an empty string and decide not to use this method.
getRequestBasePath
in interface RequestContext
public String getPathInfo()
getPathInfo
in interface RequestContext
org.apache.portals.applications.webcontent2.portlet.proxy.PortletRequestContext#getRequestBasePath()}
public Object getAttribute(String name)
getAttribute
in interface RequestContext
javax.servlet.ServletRequest#getAttribute()}
,
javax.portlet.PortletRequest#getAttribute()}
public String getQueryString()
Note: Portlet runtime doesn't give an HTTP request query string unlike servlet runtime. So, an implementation for that kind of runtime may return null and decide not to use this method.
getQueryString
in interface RequestContext
javax.servlet.http.HttpServletRequest#getQueryString()}
,
org.apache.portals.applications.webcontent2.portlet.proxy.PortletRequestContext#getQueryString()}
public Enumeration getHeaderNames()
Note: Portlet runtime doesn't have a method named getHeaderNames()
unlike servlet runtime.
So, an implementation for portlet runtime may invoke PortletRequest.getPropertyNames()
internally
instead because some portlet container implementations such as Apache Jetspeed-2 may return HTTP header names on the method call.
getHeaderNames
in interface RequestContext
javax.servlet.http.HttpServletRequest#getHeaderNames()}
,
javax.portlet.PortletRequest#getPropertyNames()}
public Enumeration getHeaders(String name)
Note: Portlet runtime doesn't have a method named getHeaders(String)
unlike servlet runtime.
So, an implementation for portlet runtime may invoke javax.portlet.PortletRequest#getProperties()
internally
instead because some portlet container implementations such as Apache Jetspeed-2 may return HTTP headers on the method call.
getHeaders
in interface RequestContext
javax.servlet.http.HttpServletRequest#getHeaders(String)}
,
javax.portlet.PortletRequest#getProperties(String)}
public String getHeader(String name)
Note: Portlet runtime doesn't have a method named getHeader(String)
unlike servlet runtime.
So, an implementation for portlet runtime may invoke PortletRequest.getProperty(String)
internally
instead because some portlet container implementations such as Apache Jetspeed-2 may return HTTP headers on the method call.
getHeader
in interface RequestContext
javax.servlet.http.HttpServletRequest#getHeader(String)}
,
javax.portlet.PortletRequest#getProperty(String)}
public InputStream getInputStream() throws IOException
java.io.InputStream
of the body of the request as binary data.getInputStream
in interface RequestContext
IOException
javax.servlet.ServletRequest#getInputStream()}
,
javax.portlet.ClientDataRequest#getPortletInputStream()}
public void setStatus(int sc)
Note: Portlet runtime doesn't allow a portlet to set the response status code unlike servlet runtime. So, an implementation for portlet runtime may store it as a member without making any impact by itself.
setStatus
in interface RequestContext
javax.servlet.http.HttpServletResponse#setStatus(int)}
,
org.apache.portals.applications.webcontent2.portlet.proxy.PortletRequestContext#setStatus(int)}
public int getStatus()
public void sendRedirect(String location) throws IOException
sendRedirect
in interface RequestContext
IOException
javax.servlet.http.HttpServletResponse#sendRedirect(String)}
,
javax.portlet.ActionResponse#sendRedirect(String)}
public void setHeader(String name, String value)
Note: Portlet runtime doesn't have a method named setHeader(String, String)
unlike servlet runtime.
So, an implementation for portlet runtime may invoke javax.portlet.PortletRequest#setProperty(String, String)
internally
instead because some portlet container implementations such as Apache Jetspeed-2 may return HTTP headers on the method call.
setHeader
in interface RequestContext
javax.servlet.http.HttpServletResponse#setHeader(String, String)}
,
javax.portlet.PortletResponse#setProperty(String, String)}
public void setIntHeader(String name, int value)
Note: Portlet runtime doesn't have a method named setIntHeader(String, int)
unlike servlet runtime.
So, an implementation for portlet runtime may invoke javax.portlet.PortletRequest#setProperty(String, String)
internally
instead because some portlet container implementations such as Apache Jetspeed-2 may return HTTP headers on the method call.
setIntHeader
in interface RequestContext
javax.servlet.http.HttpServletResponse#setIntHeader(String, String)}
,
javax.portlet.PortletResponse#setProperty(String, String)}
public void addCookie(javax.servlet.http.Cookie cookie)
addCookie
in interface RequestContext
javax.servlet.http.HttpServletResponse#addCookie(Cookie)}
,
javax.portlet.PortletResponse#addProperty(Cookie)}
public List<javax.servlet.http.Cookie> getCookies()
public Sink getSink()
Sink
instance used in the current reverse proxy processing.getSink
in interface RequestContext
Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.