org.apache.tapestry.web
Interface WebRequest

All Superinterfaces:
AttributeHolder, Describable
All Known Implementing Classes:
ServletWebRequest

public interface WebRequest
extends AttributeHolder, Describable

Contains information about the current request, including URLs, schemes, parameters, properties and attributes. This is essentially a generic version of HttpServletRequest. In some cases, certain methods will be unsupported in some implementations (such as getHeader(String) for Portlet Tapestry).

Since:
4.0
Author:
Howard M. Lewis Ship

Method Summary
 void forward(java.lang.String URL)
          Redirects to the indicated URL.
 java.lang.String getActivationPath()
          Returns the path of the resource which activated this request (this is the equivalent of the servlet path for a servlet request).
 java.lang.String getContextPath()
          Returns the portion of the request URI that indicates the context of the request.
 java.lang.String getHeader(java.lang.String name)
          Returns the value of the specified request header.
 java.util.Locale getLocale()
          Returns the preferred locale to which content should be localized, as specified by the client or by the container.
 java.util.List getParameterNames()
          Returns the names of all query parameters for this request.
 java.lang.String getParameterValue(java.lang.String parameterName)
          Returns a parameter value.
 java.lang.String[] getParameterValues(java.lang.String parameterName)
          Returns all parameter values for a particular parameter name.
 java.lang.String getPathInfo()
          Return any additional path info beyond the servlet path itself.
 java.lang.String getRemoteUser()
          Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
 java.lang.String getRequestURI()
          Returns the path portion of the request which triggered this request.
 java.lang.String getScheme()
          Returns the name of the scheme used to make this request.
 java.lang.String getServerName()
          Returns the host name of the server that received the request.
 int getServerPort()
          Returns the port number on which this request was received.
 WebSession getSession(boolean create)
          Returns the current WebSessionassociated with this request, possibly creating it if it does not already exist.
 java.security.Principal getUserPrincipal()
          Returns a java.security.Principal object containing the name of the current authenticated user.
 boolean isUserInRole(java.lang.String role)
          * Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
 
Methods inherited from interface org.apache.tapestry.web.AttributeHolder
getAttribute, getAttributeNames, setAttribute
 
Methods inherited from interface org.apache.tapestry.describe.Describable
describeTo
 

Method Detail

getParameterNames

public java.util.List getParameterNames()
Returns the names of all query parameters for this request. Note that this may return an empty list if an HTML form submission uploads files (with a request encoding of multipart/form-data). Accessing query parameters in such an event requires parsing of the request input stream.


getParameterValue

public java.lang.String getParameterValue(java.lang.String parameterName)
Returns a parameter value. If the parameter was submitted with multiple values, then the first submitted value is returned. May return null if no parameter was submitted with the given name.

Parameters:
parameterName - name of parameter to obtain
Returns:
the corresponding value, or null if a value for the parameter was not submitted in the request
See Also:
getParameterValues(String)

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String parameterName)
Returns all parameter values for a particular parameter name. May return null.

The caller should not modify the returned value.

Parameters:
parameterName - name of parameter to obtain
Returns:
the corresponding values, or null if no values for the parameter were submitted in the request
See Also:
getParameterValue(String)

getContextPath

public java.lang.String getContextPath()
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character.


getSession

public WebSession getSession(boolean create)
Returns the current WebSessionassociated with this request, possibly creating it if it does not already exist. If create is false and the request has no valid session, this method returns null. To make sure the session is properly maintained, you must call this method before the response is committed.

Parameters:
create - if true, the session will be created and returned if it does not already exist

getScheme

public java.lang.String getScheme()
Returns the name of the scheme used to make this request. For example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.


getServerName

public java.lang.String getServerName()
Returns the host name of the server that received the request. Note that behind a firewall, this may be obscured (i.e., it may be the name of the firewall server, which is not necessarily visible to clients outside the firewall).

See Also:
IRequestDecoder

getServerPort

public int getServerPort()
Returns the port number on which this request was received.


getRequestURI

public java.lang.String getRequestURI()
Returns the path portion of the request which triggered this request. Query parameters, scheme, server and port are omitted.

Note: portlets do not know their request URI.


forward

public void forward(java.lang.String URL)
Redirects to the indicated URL. If the URL is local, then a forward occurs. Otherwise, a client side redirect is returned to the client browser.


getActivationPath

public java.lang.String getActivationPath()
Returns the path of the resource which activated this request (this is the equivalent of the servlet path for a servlet request). The activation path will not end with a slash.


getPathInfo

public java.lang.String getPathInfo()
Return any additional path info beyond the servlet path itself. Path info, if non-null, begins with a path.

Returns:
path info, or null if no path info

getLocale

public java.util.Locale getLocale()
Returns the preferred locale to which content should be localized, as specified by the client or by the container. May return null.


getHeader

public java.lang.String getHeader(java.lang.String name)
Returns the value of the specified request header.

Parameters:
name - the name of the header to retrieve
Returns:
the header value as a string, or null if the header is not in the request.

getRemoteUser

public java.lang.String getRemoteUser()
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.

Returns:
a String specifying the login of the user making this request, or null if the user login is not known.

getUserPrincipal

public java.security.Principal getUserPrincipal()
Returns a java.security.Principal object containing the name of the current authenticated user.

Returns:
a java.security.Principal containing the name of the user making this request, or null if the user has not been authenticated.

isUserInRole

public boolean isUserInRole(java.lang.String role)
* Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.

Parameters:
role - a String specifying the name of the role
Returns:
a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated.