Class RequestImpl
- java.lang.Object
-
- org.apache.tapestry5.http.internal.services.RequestImpl
-
- All Implemented Interfaces:
Request
public class RequestImpl extends java.lang.Object implements Request
Basic implementation ofRequest
that wraps around anHttpServletRequest
. This is not threadsafe, nor should it need to be (each Request is handled by its own Thread).
-
-
Constructor Summary
Constructors Constructor Description RequestImpl(HttpServletRequest request, java.lang.String applicationCharset, TapestrySessionFactory sessionFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getAttribute(java.lang.String name)
Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists.java.util.List<java.lang.String>
getAttributeNames()
Returns a sorted list of attribute names.java.lang.String
getContextPath()
Returns the context path.long
getDateHeader(java.lang.String name)
Returns the value of the specified request header as along
value that represents aDate
object.java.lang.String
getHeader(java.lang.String name)
Returns the named header as a string, or null if not found.java.util.List<java.lang.String>
getHeaderNames()
Returns the names of all headers in the request.java.util.Locale
getLocale()
Returns the locale of the client as determined from the request headers.int
getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received.java.lang.String
getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.java.lang.String
getParameter(java.lang.String name)
Returns the query parameter value for the given name.java.util.List<java.lang.String>
getParameterNames()
Returns a list of query parameter names, in alphabetical order.java.lang.String[]
getParameters(java.lang.String name)
Returns the parameter values for the given name.java.lang.String
getPath()
Returns the path portion of the request, which starts with a "/" and contains everything up to the start of the query parameters.java.lang.String
getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request.java.lang.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.Session
getSession(boolean create)
Gets theSession
.boolean
isRequestedSessionIdValid()
Checks whether the requested session ID is still valid.boolean
isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.boolean
isSessionInvalidated()
Returns true if the request specified a session, and that session has been invalidated.boolean
isXHR()
Returns true if the request originated on the client using XmlHttpRequest (the core of any Ajax behavior).void
setAttribute(java.lang.String name, java.lang.Object value)
Stores an attribute in this request.
-
-
-
Constructor Detail
-
RequestImpl
public RequestImpl(HttpServletRequest request, java.lang.String applicationCharset, TapestrySessionFactory sessionFactory)
-
-
Method Detail
-
getParameterNames
public java.util.List<java.lang.String> getParameterNames()
Description copied from interface:Request
Returns a list of query parameter names, in alphabetical order.- Specified by:
getParameterNames
in interfaceRequest
-
getHeaderNames
public java.util.List<java.lang.String> getHeaderNames()
Description copied from interface:Request
Returns the names of all headers in the request.- Specified by:
getHeaderNames
in interfaceRequest
-
getParameter
public java.lang.String getParameter(java.lang.String name)
Description copied from interface:Request
Returns the query parameter value for the given name. Returns null if no such parameter is in the request. For a multi-valued parameter, returns just the first value.- Specified by:
getParameter
in interfaceRequest
-
getParameters
public java.lang.String[] getParameters(java.lang.String name)
Description copied from interface:Request
Returns the parameter values for the given name. Returns null if no such parameter is in the request.- Specified by:
getParameters
in interfaceRequest
-
getHeader
public java.lang.String getHeader(java.lang.String name)
Description copied from interface:Request
Returns the named header as a string, or null if not found.
-
getPath
public java.lang.String getPath()
Description copied from interface:Request
Returns the path portion of the request, which starts with a "/" and contains everything up to the start of the query parameters. It doesn't include the context path.
-
getContextPath
public java.lang.String getContextPath()
Description copied from interface:Request
Returns the context path. This always starts with a "/" character and does not end with one, with the exception of servlets in the root context, which return the empty string.- Specified by:
getContextPath
in interfaceRequest
-
isSessionInvalidated
public boolean isSessionInvalidated()
Description copied from interface:Request
Returns true if the request specified a session, and that session has been invalidated.- Specified by:
isSessionInvalidated
in interfaceRequest
- Returns:
- true if session was invalidated during this request
-
getSession
public Session getSession(boolean create)
Description copied from interface:Request
Gets theSession
. If create is false and the session has not be created previously, returns null. Also, if the session is invalidated and create is false, returns null. Invoking this method with true, when the session exists but has been invalidated, will force the creation of a new session.- Specified by:
getSession
in interfaceRequest
- Parameters:
create
- true to force the creation of the session- Returns:
- the session (or null if create is false the session has not been previously created)
-
getLocale
public java.util.Locale getLocale()
Description copied from interface:Request
Returns the locale of the client as determined from the request headers.
-
getDateHeader
public long getDateHeader(java.lang.String name)
Description copied from interface:Request
Returns the value of the specified request header as along
value that represents aDate
object. Use this method with headers that contain dates, such asIf-Modified-Since
. The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive. If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws anIllegalArgumentException
.- Specified by:
getDateHeader
in interfaceRequest
- Parameters:
name
- aString
specifying the name of the header- Returns:
- a
long
value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the reqest
-
isXHR
public boolean isXHR()
Description copied from interface:Request
Returns true if the request originated on the client using XmlHttpRequest (the core of any Ajax behavior). Ajax action requests may behave quite differently than ordinary, page-based requests. This implementation currently depends on the client side setting a header: X-Requested-With=XMLHttpRequest (this is what Prototype does).
-
isSecure
public boolean isSecure()
Description copied from interface:Request
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
Description copied from interface:Request
Checks whether the requested session ID is still valid.- Specified by:
isRequestedSessionIdValid
in interfaceRequest
- Returns:
- true if the request included a session id that is still active, false if the included session id has expired
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface:Request
Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists. Because this method is a wrapper aroundServletRequest.getAttribute(String)
, it is case sensitive (unlike most of Tapestry).- Specified by:
getAttribute
in interfaceRequest
- Parameters:
name
- aString
specifying the name of the attribute- Returns:
- an
Object
containing the value of the attribute, ornull
if the attribute does not exist
-
getAttributeNames
public java.util.List<java.lang.String> getAttributeNames()
Description copied from interface:Request
Returns a sorted list of attribute names.- Specified by:
getAttributeNames
in interfaceRequest
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
Description copied from interface:Request
Stores an attribute in this request. Attributes are reset between requests (and remember that in Tapestry, there is usually two requests per operation: the action request that redirects to a render request).- Specified by:
setAttribute
in interfaceRequest
- Parameters:
name
- aString
specifying the name of the attributevalue
- theObject
to be stored, or null to remove the attribute
-
getMethod
public java.lang.String getMethod()
Description copied from interface:Request
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
-
getServerName
public java.lang.String getServerName()
Description copied from interface:Request
Returns the host name of the server to which the request was sent. It is the value of the part before ":" in theHost
header, if any, or the resolved server name, or the server IP address.- Specified by:
getServerName
in interfaceRequest
- Returns:
- the name of the server
-
getLocalPort
public int getLocalPort()
Description copied from interface:Request
Returns the Internet Protocol (IP) port number of the interface on which the request was received.- Specified by:
getLocalPort
in interfaceRequest
- Returns:
- an integer specifying the port number
-
getServerPort
public int getServerPort()
Description copied from interface:Request
Returns the port number to which the request was sent. It is the value of the part after ":" in theHost
header, if any, or the server port where the client connection was accepted on.- Specified by:
getServerPort
in interfaceRequest
- Returns:
- an integer specifying the port number
- Since:
- 5.2.5
-
getRemoteHost
public java.lang.String getRemoteHost()
Description copied from interface:Request
Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.- Specified by:
getRemoteHost
in interfaceRequest
- Returns:
- a
String
containing the fully qualified name of the client
-
-