jrun.servlet
Class ForwardRequest

jrun.servlet.RequestWrapper
  |
  +--jrun.servlet.ForwardRequest

public final class ForwardRequest
extends RequestWrapper

This class wraps a request object so that it can override the path component methods in the servlet API. If the query string passed in is not null, then we parse it and make the parameters available as well.

This request object that will be exposed directly to servlets. In JRun, request objects are layered (this object will wrap a protocol- specific subclass of JRunRequest). This is the "top" layer that contains a reference to the ServletContext for the current servlet, and contains any logic that is specific to this servlet context.

currently, this logic includes the URI path components, session tracking, authentication, and convenience methods that use getRealPath and getRequestDispatcher from the current servlet context.

This class is final because it is optimized to short-circuit the nesting of multiple ForwardRequests. This short-circuit logic would break if a subclass were involved. In addition, making this class final enables inlining.


Method Summary
 java.lang.String getAuthType()
           
 java.lang.String getContextPath()
           
 java.lang.String getParameter(java.lang.String name)
           
 java.util.Map getParameterMap()
           
 java.util.Enumeration getParameterNames()
           
 java.lang.String[] getParameterValues(java.lang.String name)
          Returns the values of the specified parameter for the request as an array of strings, or null if the named parameter does not exist.
 java.lang.String getPathInfo()
           
 java.lang.String getPathTranslated()
           
 java.lang.String getQueryString()
           
 java.lang.String getRealPath(java.lang.String path)
           
 java.lang.String getRemoteUser()
           
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String relativePath)
          Gets a request dispatcher from the current servlet context.
 java.lang.String getRequestedSessionId()
          Find and return the session id using this application's session manager service.
 java.lang.String getRequestURI()
           
 java.lang.StringBuffer getRequestURL()
           
 java.lang.String getServletName()
          Gets the name of the current servlet being serviced
 java.lang.String getServletPath()
           
 javax.servlet.http.HttpSession getSession()
           
 javax.servlet.http.HttpSession getSession(boolean create)
          use this application's session manager to find and/or create a new session object.
 java.security.Principal getUserPrincipal()
          Get the current session and check for an authenticated user.
 boolean isRequestedSessionIdFromCookie()
           
 boolean isRequestedSessionIdFromUrl()
           
 boolean isRequestedSessionIdFromURL()
           
 boolean isRequestedSessionIdValid()
           
 boolean isUserInRole(java.lang.String role)
           
 void setCharacterEncoding(java.lang.String enc)
           
protected  void setRequest(javax.servlet.http.HttpServletRequest request)
           
 void setServletName(java.lang.String name)
          Sets the name of the current servlet being serviced
 
Methods inherited from class jrun.servlet.RequestWrapper
getHttpRequest, getRequestWrapper, setRequestWrapper
 

Method Detail

setRequest

protected void setRequest(javax.servlet.http.HttpServletRequest request)

getContextPath

public java.lang.String getContextPath()

getRequestURI

public java.lang.String getRequestURI()

getServletPath

public java.lang.String getServletPath()

getPathInfo

public java.lang.String getPathInfo()

getQueryString

public java.lang.String getQueryString()

getParameter

public java.lang.String getParameter(java.lang.String name)

getRequestURL

public java.lang.StringBuffer getRequestURL()

getParameterMap

public java.util.Map getParameterMap()

setCharacterEncoding

public void setCharacterEncoding(java.lang.String enc)
                          throws java.io.UnsupportedEncodingException

getParameterNames

public java.util.Enumeration getParameterNames()

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Returns the values of the specified parameter for the request as an array of strings, or null if the named parameter does not exist.

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String relativePath)
Gets a request dispatcher from the current servlet context. If the path is relative (doesn't start with '/') then it is interpreted relative to the servlet path of this request. (i.e. the value of getServletPath). Otherwise, if the path begins with '/', this method is equivalent to calling ServletContext.getRequestDispatcher().
Parameters:
relativePath - a path that is relative to this application or this request.

getSession

public javax.servlet.http.HttpSession getSession()

getSession

public javax.servlet.http.HttpSession getSession(boolean create)
use this application's session manager to find and/or create a new session object. If we already have a requested session id and it is valid, then we use it. This lets multiple applications share a single session tracking cookie.

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Find and return the session id using this application's session manager service. Each application can have its own, which allows each application to use a different cookie name, for example.

This will return the requested session id, which in theory could be different from the session id on this request's session object.

Returns:
the requested session id, or null if we can't find it.

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()

getRemoteUser

public java.lang.String getRemoteUser()

getAuthType

public java.lang.String getAuthType()

getUserPrincipal

public java.security.Principal getUserPrincipal()
Get the current session and check for an authenticated user.

isUserInRole

public boolean isUserInRole(java.lang.String role)

setServletName

public void setServletName(java.lang.String name)
Sets the name of the current servlet being serviced
Parameters:
name - The servlet name

getServletName

public java.lang.String getServletName()
Gets the name of the current servlet being serviced
Returns:
The servlet name

getRealPath

public java.lang.String getRealPath(java.lang.String path)

getPathTranslated

public final java.lang.String getPathTranslated()
Returns:
getRealPath(getPathInfo()), possibly null


Copyright � 2002 Macromedia Corporation. All Rights Reserved.