com.caucho.portal.generic
Class HttpPortletRequestDispatcher.HttpPortletRequestWrapper

java.lang.Object
  extended by com.caucho.portal.generic.HttpPortletRequestDispatcher.HttpPortletRequestWrapper
All Implemented Interfaces:
HttpServletRequest, ServletRequest
Enclosing class:
HttpPortletRequestDispatcher

protected static class HttpPortletRequestDispatcher.HttpPortletRequestWrapper
extends java.lang.Object
implements HttpServletRequest

This can't extend HttpServletRequestWrapper because of some bizarre behaviour mandated by the Servlet spec.


Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
HttpPortletRequestDispatcher.HttpPortletRequestWrapper()
           
 
Method Summary
 void complete()
          Complete the request
 void finish()
           
 java.lang.Object getAttribute(java.lang.String name)
          Returns an attribute value.
 java.util.Enumeration getAttributeNames()
          Enumerates all attribute names in the request.
 java.lang.String getAuthType()
          Returns the auth type, i.e.
 java.lang.String getCharacterEncoding()
          Returns the character encoding of the POSTed data.
 int getContentLength()
          Returns the content length of the data.
 java.lang.String getContentType()
          Returns the request's mime-type.
 java.lang.String getContextPath()
          Returns the part of the URI corresponding to the application's prefix.
 Cookie[] getCookies()
          Returns an array of all cookies sent by the client.
 long getDateHeader(java.lang.String name)
          Converts a date header to milliseconds since the epoch.
 java.lang.String getHeader(java.lang.String name)
          Returns the first value for a request header.
 java.util.Enumeration getHeaderNames()
          Returns an enumeration of all headers sent by the client.
 java.util.Enumeration getHeaders(java.lang.String name)
          Returns all the values for a request header.
 ServletInputStream getInputStream()
          Returns an InputStream to retrieve POST data from the request.
 int getIntHeader(java.lang.String name)
          Converts a header value to an integer.
 java.lang.String getLocalAddr()
          This call returns the ip of the host actually used to connect to the Resin server, which means that if ipchains, load balancing, or proxying is involved this call does not return the correct host for forming urls.
 java.util.Locale getLocale()
          Returns the request's preferred locale, based on the Accept-Language header.
 java.util.Enumeration getLocales()
          Returns an enumeration of all locales acceptable by the client.
 java.lang.String getLocalName()
          Returns the IP address of the local host, i.e.
 int getLocalPort()
          Returns the port of the local host.
 java.lang.String getMethod()
          Returns the HTTP method, e.g.
 java.lang.String getParameter(java.lang.String name)
          Returns a form parameter.
 java.util.Map getParameterMap()
          Returns a Map of the form parameters.
 java.util.Enumeration getParameterNames()
          Returns an enumeration of all form parameter names.
 java.lang.String[] getParameterValues(java.lang.String name)
          Returns all values of a form parameter.
 java.lang.String getPathInfo()
          Returns the URI part after the selected servlet and null if there is no suffix.
 java.lang.String getPathTranslated()
          Returns the physical path name for the path info.
 java.lang.String getProtocol()
          Returns the prococol, e.g.
 java.lang.String getQueryString()
          Returns the request's query string.
 java.io.BufferedReader getReader()
          Returns a reader to read POSTed data.
 java.lang.String getRealPath(java.lang.String uri)
          Returns the path of the URI.
 java.lang.String getRemoteAddr()
          Returns the IP address of the remote host, i.e.
 java.lang.String getRemoteHost()
          Returns the DNS hostname of the remote host, i.e.
 int getRemotePort()
          Returns the port of the remote host, i.e.
 java.lang.String getRemoteUser()
          Returns the remote user if authenticated.
 RequestDispatcher getRequestDispatcher(java.lang.String uri)
          Returns a request dispatcher for later inclusion or forwarding.
 java.lang.String getRequestedSessionId()
          Returns the session id.
 java.lang.String getRequestURI()
          Returns the entire request URI
 java.lang.StringBuffer getRequestURL()
          Reconstructs the URL the client used for the request.
 java.lang.String getScheme()
          Returns the request scheme, e.g.
 java.lang.String getServerName()
          Returns the server name handling the request.
 int getServerPort()
          Returns the server port used by the client, e.g.
 ServletContext getServletContext()
          Returns the servlet context for the request
 java.lang.String getServletPath()
          Returns the URI part corresponding to the selected servlet.
 ServletResponse getServletResponse()
          Returns the servlet response for the request
 HttpSession getSession()
          Returns the current session, creating one if necessary.
 HttpSession getSession(boolean create)
          Returns a session.
 java.security.Principal getUserPrincipal()
          Returns the equivalent principal object for the authenticated user.
 boolean isInitial()
          Returns true for the initial dispatch
 boolean isRequestedSessionIdFromCookie()
          Returns true if the session came from a cookie.
 boolean isRequestedSessionIdFromUrl()
          Deprecated.  
 boolean isRequestedSessionIdFromURL()
          Returns true if the session came URL-encoding.
 boolean isRequestedSessionIdValid()
          Returns true if the session is valid.
 boolean isResumed()
          Returns true if the servlet is resumed
 boolean isSecure()
          Returns true if the connection is secure, e.g.
 boolean isSuspended()
          Returns true if the servlet is suspended
 boolean isTimeout()
          Returns true if the servlet timed out
 boolean isUserInRole(java.lang.String role)
          Returns true if the user is in the given role.
 void removeAttribute(java.lang.String name)
          Removes the given attribute.
 void resume()
          Resume the request
 void setAttribute(java.lang.String name, java.lang.Object o)
          Sets an attribute value.
 void setCharacterEncoding(java.lang.String encoding)
          Overrides the character encoding specified in the request.
 void start(HttpServletRequest httpRequest, RenderRequest renderRequest, java.util.Map<java.lang.String,java.lang.String[]> parameterMap)
           
 void suspend()
          Suspend the request
 void suspend(long timeout)
          Suspend the request
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpPortletRequestDispatcher.HttpPortletRequestWrapper

public HttpPortletRequestDispatcher.HttpPortletRequestWrapper()
Method Detail

start

public void start(HttpServletRequest httpRequest,
                  RenderRequest renderRequest,
                  java.util.Map<java.lang.String,java.lang.String[]> parameterMap)

finish

public void finish()

getParameter

public java.lang.String getParameter(java.lang.String name)
Description copied from interface: ServletRequest
Returns a form parameter. When the form contains several parameters of the same name, getParameter returns the first.

For example, calling getParameter("a") with the the query string a=1&a=2 will return "1".

Specified by:
getParameter in interface ServletRequest
Parameters:
name - the form parameter to return
Returns:
the form value or null if none matches.

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Description copied from interface: ServletRequest
Returns all values of a form parameter.

For example, calling getParameterValues("a") with the the query string a=1&a=2 will return ["1", "2"].

Specified by:
getParameterValues in interface ServletRequest
Parameters:
name - the form parameter to return
Returns:
an array of matching form values or null if none matches.

getParameterMap

public java.util.Map getParameterMap()
Description copied from interface: ServletRequest
Returns a Map of the form parameters. The map is immutable. The keys are the form keys as returned by getParameterNames and the values are String arrays as returned by getParameterValues.

Specified by:
getParameterMap in interface ServletRequest

getParameterNames

public java.util.Enumeration getParameterNames()
Description copied from interface: ServletRequest
Returns an enumeration of all form parameter names.
 Enumeration e = request.getParameterNames();
 while (e.hasMoreElements()) {
   String name = (String) e.nextElement();
   out.println(name + ": " + request.getParameter(name));
 }
 

Specified by:
getParameterNames in interface ServletRequest

getScheme

public java.lang.String getScheme()
Description copied from interface: ServletRequest
Returns the request scheme, e.g. "http"

Specified by:
getScheme in interface ServletRequest

getServerName

public java.lang.String getServerName()
Description copied from interface: ServletRequest
Returns the server name handling the request. When using virtual hosts, this returns the virtual host name, e.g. "vhost1.caucho.com". This call returns the host name as the client sees it, which means that if ipchains, load balancing, or proxying is involved this call returns the correct call for forming urls, but may not contain the host that Resin is actually listening on.

Specified by:
getServerName in interface ServletRequest

getServerPort

public int getServerPort()
Description copied from interface: ServletRequest
Returns the server port used by the client, e.g. 80. This call returns the port number as the client sees it, which means that if ipchains, load balancing, or proxying is involved this call returns the correct call for forming urls, but may not return the actual port that Resin is listening on. This call should not be used to test for an ssl connection (getServerPort() == 443), ServletRequest.isSecure() is provided for that purpose.

Specified by:
getServerPort in interface ServletRequest

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface: ServletRequest
Returns an attribute value.

Specified by:
getAttribute in interface ServletRequest
Parameters:
name - the attribute name
Returns:
the attribute value

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object o)
Description copied from interface: ServletRequest
Sets an attribute value.

Specified by:
setAttribute in interface ServletRequest
Parameters:
name - the attribute name
o - the attribute value

getAttributeNames

public java.util.Enumeration getAttributeNames()
Description copied from interface: ServletRequest
Enumerates all attribute names in the request.

Specified by:
getAttributeNames in interface ServletRequest

removeAttribute

public void removeAttribute(java.lang.String name)
Description copied from interface: ServletRequest
Removes the given attribute.

Specified by:
removeAttribute in interface ServletRequest
Parameters:
name - the attribute name

getLocale

public java.util.Locale getLocale()
Description copied from interface: ServletRequest
Returns the request's preferred locale, based on the Accept-Language header. If unspecified, returns the server's default locale.

Specified by:
getLocale in interface ServletRequest

getLocales

public java.util.Enumeration getLocales()
Description copied from interface: ServletRequest
Returns an enumeration of all locales acceptable by the client.

Specified by:
getLocales in interface ServletRequest

isSecure

public boolean isSecure()
Description copied from interface: ServletRequest
Returns true if the connection is secure, e.g. it uses SSL.

Specified by:
isSecure in interface ServletRequest

getAuthType

public java.lang.String getAuthType()
Description copied from interface: HttpServletRequest
Returns the auth type, i.e. BASIC, CLIENT-CERT, DIGEST, or FORM.

Specified by:
getAuthType in interface HttpServletRequest

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Description copied from interface: HttpServletRequest
Returns the session id. Sessions are a convenience for keeping user state across requests.

The session id is the value of the JSESSION cookie.

Specified by:
getRequestedSessionId in interface HttpServletRequest

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Description copied from interface: HttpServletRequest
Returns true if the session is valid.

Specified by:
isRequestedSessionIdValid in interface HttpServletRequest

getRemoteUser

public java.lang.String getRemoteUser()
Description copied from interface: HttpServletRequest
Returns the remote user if authenticated.

Specified by:
getRemoteUser in interface HttpServletRequest

isUserInRole

public boolean isUserInRole(java.lang.String role)
Description copied from interface: HttpServletRequest
Returns true if the user is in the given role.

Specified by:
isUserInRole in interface HttpServletRequest

getUserPrincipal

public java.security.Principal getUserPrincipal()
Description copied from interface: HttpServletRequest
Returns the equivalent principal object for the authenticated user.

Specified by:
getUserPrincipal in interface HttpServletRequest

getHeader

public java.lang.String getHeader(java.lang.String name)
Description copied from interface: HttpServletRequest
Returns the first value for a request header.

Corresponds to CGI's HTTP_*

 String userAgent = request.getHeader("User-Agent");
 

Specified by:
getHeader in interface HttpServletRequest
Parameters:
name - the header name
Returns:
the header value

getHeaders

public java.util.Enumeration getHeaders(java.lang.String name)
Description copied from interface: HttpServletRequest
Returns all the values for a request header. In some rare cases, like cookies, browsers may return multiple headers.

Specified by:
getHeaders in interface HttpServletRequest
Parameters:
name - the header name
Returns:
an enumeration of the header values.

getHeaderNames

public java.util.Enumeration getHeaderNames()
Description copied from interface: HttpServletRequest
Returns an enumeration of all headers sent by the client.

Specified by:
getHeaderNames in interface HttpServletRequest

getIntHeader

public int getIntHeader(java.lang.String name)
Description copied from interface: HttpServletRequest
Converts a header value to an integer.

Specified by:
getIntHeader in interface HttpServletRequest
Parameters:
name - the header name
Returns:
the header value converted to an integer

getDateHeader

public long getDateHeader(java.lang.String name)
Description copied from interface: HttpServletRequest
Converts a date header to milliseconds since the epoch.

 long mod = request.getDateHeader("If-Modified-Since");
 

Specified by:
getDateHeader in interface HttpServletRequest
Parameters:
name - the header name
Returns:
the header value converted to an date

getCookies

public Cookie[] getCookies()
Description copied from interface: HttpServletRequest
Returns an array of all cookies sent by the client.

Specified by:
getCookies in interface HttpServletRequest

getProtocol

public java.lang.String getProtocol()
Description copied from interface: ServletRequest
Returns the prococol, e.g. "HTTP/1.1"

Specified by:
getProtocol in interface ServletRequest

getRealPath

public java.lang.String getRealPath(java.lang.String uri)
Description copied from interface: ServletRequest
Returns the path of the URI.

Specified by:
getRealPath in interface ServletRequest

getRequestURL

public java.lang.StringBuffer getRequestURL()
Description copied from interface: HttpServletRequest
Reconstructs the URL the client used for the request.

Specified by:
getRequestURL in interface HttpServletRequest

getRemoteAddr

public java.lang.String getRemoteAddr()
Description copied from interface: ServletRequest
Returns the IP address of the remote host, i.e. the client browser.

Specified by:
getRemoteAddr in interface ServletRequest

getRemoteHost

public java.lang.String getRemoteHost()
Description copied from interface: ServletRequest
Returns the DNS hostname of the remote host, i.e. the client browser.

Specified by:
getRemoteHost in interface ServletRequest

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Description copied from interface: ServletRequest
Returns the character encoding of the POSTed data.

Specified by:
getCharacterEncoding in interface ServletRequest

setCharacterEncoding

public void setCharacterEncoding(java.lang.String encoding)
                          throws java.io.UnsupportedEncodingException
Description copied from interface: ServletRequest
Overrides the character encoding specified in the request. setCharacterEncoding must be called before calling getReader or reading any parameters.

Specified by:
setCharacterEncoding in interface ServletRequest
Throws:
java.io.UnsupportedEncodingException

getInputStream

public ServletInputStream getInputStream()
                                  throws java.io.IOException
Description copied from interface: ServletRequest
Returns an InputStream to retrieve POST data from the request. The stream will automatically end when the end of the POST data is complete.

Specified by:
getInputStream in interface ServletRequest
Throws:
java.io.IOException

getReader

public java.io.BufferedReader getReader()
                                 throws java.io.IOException,
                                        java.lang.IllegalStateException
Description copied from interface: ServletRequest
Returns a reader to read POSTed data. Character encoding is based on the request data and is the same as getCharacterEncoding()

Specified by:
getReader in interface ServletRequest
Throws:
java.io.IOException
java.lang.IllegalStateException

getContentLength

public int getContentLength()
Description copied from interface: ServletRequest
Returns the content length of the data. This value may differ from the actual length of the data. Newer browsers supporting HTTP/1.1 may use "chunked" encoding which does not make the content length available.

The upshot is, rely on the input stream to end when the data completes.

Specified by:
getContentLength in interface ServletRequest

getMethod

public java.lang.String getMethod()
Description copied from interface: HttpServletRequest
Returns the HTTP method, e.g. "GET" or "POST"

Equivalent to CGI's REQUEST_METHOD

Specified by:
getMethod in interface HttpServletRequest

getRemotePort

public int getRemotePort()
Description copied from interface: ServletRequest
Returns the port of the remote host, i.e. the client browser.

Specified by:
getRemotePort in interface ServletRequest

getLocalAddr

public java.lang.String getLocalAddr()
Description copied from interface: ServletRequest
This call returns the ip of the host actually used to connect to the Resin server, which means that if ipchains, load balancing, or proxying is involved this call does not return the correct host for forming urls.

Specified by:
getLocalAddr in interface ServletRequest

getLocalName

public java.lang.String getLocalName()
Description copied from interface: ServletRequest
Returns the IP address of the local host, i.e. the server. This call returns the name of the host actaully used to connect to the Resin server, which means that if ipchains, load balancing, or proxying is involved this call does not return the correct host for forming urls.

Specified by:
getLocalName in interface ServletRequest

getLocalPort

public int getLocalPort()
Description copied from interface: ServletRequest
Returns the port of the local host. This call returns the port number actually used to connect to the Resin server, which means that if ipchains, load balancing, or proxying is involved this call does not return the correct port for forming urls. This call should not be used to test for an ssl connection (getServerPort() == 443), ServletRequest.isSecure() is provided for that purpose.

Specified by:
getLocalPort in interface ServletRequest

getContentType

public java.lang.String getContentType()
Description copied from interface: ServletRequest
Returns the request's mime-type.

Specified by:
getContentType in interface ServletRequest

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(java.lang.String uri)
Description copied from interface: ServletRequest
Returns a request dispatcher for later inclusion or forwarding. This is the servlet API equivalent to SSI includes. uri is relative to the request URI. Absolute URIs are relative to the application prefix (getContextPath()).

If getRequestURI() is /myapp/dir/test.jsp and the uri is "inc.jsp", the resulting page is /myapp/dir/inc.jsp.

   RequestDispatcher disp;
   disp = getRequestDispatcher("inc.jsp?a=b");
   disp.include(request, response);
 

Specified by:
getRequestDispatcher in interface ServletRequest
Parameters:
uri - path relative to getRequestURI() (including query string) for the included file.
Returns:
RequestDispatcher for later inclusion or forwarding.

getRequestURI

public java.lang.String getRequestURI()
Description copied from interface: HttpServletRequest
Returns the entire request URI

Specified by:
getRequestURI in interface HttpServletRequest

getContextPath

public java.lang.String getContextPath()
Description copied from interface: HttpServletRequest
Returns the part of the URI corresponding to the application's prefix. The first part of the URI selects applications (ServletContexts).

getContextPath() is /myapp for the uri /myapp/servlet/Hello,

Specified by:
getContextPath in interface HttpServletRequest

getServletPath

public java.lang.String getServletPath()
Description copied from interface: HttpServletRequest
Returns the URI part corresponding to the selected servlet. The URI is relative to the application.

Corresponds to CGI's SCRIPT_NAME getServletPath() is /servlet/Hello for the uri /myapp/servlet/Hello/foo. getServletPath() is /dir/hello.jsp for the uri /myapp/dir/hello.jsp/foo,

Specified by:
getServletPath in interface HttpServletRequest

getPathInfo

public java.lang.String getPathInfo()
Description copied from interface: HttpServletRequest
Returns the URI part after the selected servlet and null if there is no suffix.

Corresponds to CGI's PATH_INFO

getPathInfo() is /foo for the uri /myapp/servlet/Hello/foo. getPathInfo() is /hello.jsp for for the uri /myapp/dir/hello.jsp/foo.

Specified by:
getPathInfo in interface HttpServletRequest

getPathTranslated

public java.lang.String getPathTranslated()
Description copied from interface: HttpServletRequest
Returns the physical path name for the path info.

Corresponds to CGI's PATH_TRANSLATED

Specified by:
getPathTranslated in interface HttpServletRequest
Returns:
null if there is no path info.

getQueryString

public java.lang.String getQueryString()
Description copied from interface: HttpServletRequest
Returns the request's query string. Form based servlets will use ServletRequest.getParameter() to decode the form values.

Corresponds to CGI's PATH_TRANSLATED

Specified by:
getQueryString in interface HttpServletRequest

getSession

public HttpSession getSession(boolean create)
Description copied from interface: HttpServletRequest
Returns a session. If no session exists and create is true, then create a new session, otherwise return null.

Specified by:
getSession in interface HttpServletRequest
Parameters:
create - If true, then create a new session if none exists.

getSession

public HttpSession getSession()
Description copied from interface: HttpServletRequest
Returns the current session, creating one if necessary. Sessions are a convenience for keeping user state across requests.

Specified by:
getSession in interface HttpServletRequest

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Description copied from interface: HttpServletRequest
Returns true if the session came from a cookie.

Specified by:
isRequestedSessionIdFromCookie in interface HttpServletRequest

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()
Description copied from interface: HttpServletRequest
Returns true if the session came URL-encoding.

Specified by:
isRequestedSessionIdFromURL in interface HttpServletRequest

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()
Deprecated. 

Specified by:
isRequestedSessionIdFromUrl in interface HttpServletRequest

getServletContext

public ServletContext getServletContext()
Returns the servlet context for the request

Specified by:
getServletContext in interface ServletRequest
Since:
Servlet 3.0

getServletResponse

public ServletResponse getServletResponse()
Returns the servlet response for the request

Specified by:
getServletResponse in interface ServletRequest
Since:
Servlet 3.0

suspend

public void suspend(long timeout)
Suspend the request

Specified by:
suspend in interface ServletRequest
Since:
Servlet 3.0

suspend

public void suspend()
Suspend the request

Specified by:
suspend in interface ServletRequest
Since:
Servlet 3.0

resume

public void resume()
Resume the request

Specified by:
resume in interface ServletRequest
Since:
Servlet 3.0

complete

public void complete()
Complete the request

Specified by:
complete in interface ServletRequest
Since:
Servlet 3.0

isSuspended

public boolean isSuspended()
Returns true if the servlet is suspended

Specified by:
isSuspended in interface ServletRequest
Since:
Servlet 3.0

isResumed

public boolean isResumed()
Returns true if the servlet is resumed

Specified by:
isResumed in interface ServletRequest
Since:
Servlet 3.0

isTimeout

public boolean isTimeout()
Returns true if the servlet timed out

Specified by:
isTimeout in interface ServletRequest
Since:
Servlet 3.0

isInitial

public boolean isInitial()
Returns true for the initial dispatch

Specified by:
isInitial in interface ServletRequest
Since:
Servlet 3.0