Class ServletRequest
java.lang.Object
org.apache.tiles.request.AbstractRequest
org.apache.tiles.request.AbstractClientRequest
org.apache.tiles.request.jakarta.servlet.ServletRequest
- All Implemented Interfaces:
DispatchRequest
,Request
Servlet-based implementation of the TilesApplicationContext interface.
Copied from Apache tiles-request-servlet 1.0.7 and adapted for Jakarta EE 9.
-
Field Summary
Fields inherited from class org.apache.tiles.request.AbstractRequest
FORCE_INCLUDE_ATTRIBUTE_NAME
Fields inherited from interface org.apache.tiles.request.Request
APPLICATION_SCOPE, REQUEST_SCOPE
-
Constructor Summary
ConstructorDescriptionServletRequest
(ApplicationContext applicationContext, HttpServletRequest request, HttpServletResponse response) Creates a new instance of ServletTilesRequestContext. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Forwards to a path.void
Includes the content of a resource (servlet, JSP page, HTML file) in the response.Returns all available scopes.getContext
(String scope) Returns a context map, given the scope name.Return an immutable Map that maps header names to the first (or only) header value (as a String).Return an immutable Map that maps header names to the set of all values specified in the request (as a String array).Returns aServletOutputStream
suitable for writing binary data in the response.getParam()
Return an immutable Map that maps request parameter names to the first (or only) value (as a String).Return an immutable Map that maps request parameter names to the set of all values (as a String array).Returns aPrintWriter
object that can send character text to the client.Returns the request object to use.Returns the preferredLocale
that the client will accept content in, based on the Accept-Language header.Returns the context map from request scope.Returns the response object to use.Return an add-able object that can be used to write headers to the response.Returns the context map from session scope.Returns aWriter
object that can send character text to the client.boolean
Returns a boolean indicating if the response has been committed.boolean
isUserInRole
(String role) Returns a boolean indicating whether the authenticated user is included in the specified logical "role".void
setContentType
(String contentType) Sets the content type of the response being sent to the client, if the response has not been committed yet.Methods inherited from class org.apache.tiles.request.AbstractClientRequest
dispatch, getApplicationContext, getApplicationScope, include
Methods inherited from class org.apache.tiles.request.AbstractRequest
isForceInclude, setForceInclude
-
Constructor Details
-
ServletRequest
public ServletRequest(ApplicationContext applicationContext, HttpServletRequest request, HttpServletResponse response) Creates a new instance of ServletTilesRequestContext.- Parameters:
applicationContext
- The application context.request
- The request object.response
- The response object.
-
-
Method Details
-
getHeader
Return an immutable Map that maps header names to the first (or only) header value (as a String).- Returns:
- The header map.
-
getResponseHeaders
Return an add-able object that can be used to write headers to the response.- Returns:
- An add-able object.
-
getHeaderValues
Return an immutable Map that maps header names to the set of all values specified in the request (as a String array). Header names must be matched in a case-insensitive manner.- Returns:
- The header values map.
-
getParam
Return an immutable Map that maps request parameter names to the first (or only) value (as a String).- Returns:
- The parameter map.
-
getParamValues
Return an immutable Map that maps request parameter names to the set of all values (as a String array).- Returns:
- The parameter values map.
-
getContext
Returns a context map, given the scope name.This method always return a map for all the scope names returned by
getAvailableScopes()
. That map may be writable, or immutable, depending on the implementation.- Parameters:
scope
- The name of the scope.- Returns:
- The context.
-
getRequestScope
Returns the context map from request scope.- Returns:
- the context map from request scope
-
getSessionScope
Returns the context map from session scope.- Returns:
- the context map from session scope
-
getAvailableScopes
Returns all available scopes.The scopes are ordered according to their lifetime, the innermost, shorter lived scope appears first, and the outermost, longer lived scope appears last. Besides, the scopes "request" and "application" always included in the list.
- Returns:
- All the available scopes.
-
doForward
Forwards to a path.- Specified by:
doForward
in classAbstractClientRequest
- Parameters:
path
- The path to forward to.- Throws:
IOException
- If something goes wrong when forwarding.
-
doInclude
Includes the content of a resource (servlet, JSP page, HTML file) in the response. In essence, this method enables programmatic server-side includes.- Specified by:
doInclude
in classAbstractClientRequest
- Parameters:
path
- aString
specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.- Throws:
IOException
- if the included resource throws this exception- See Also:
-
getOutputStream
Returns aServletOutputStream
suitable for writing binary data in the response. The servlet container does not encode the binary data.- Returns:
- a
ServletOutputStream
for writing binary data - Throws:
IllegalStateException
- if thegetWriter
method has been called on this responseIOException
- if an input or output exception occurred- See Also:
-
getWriter
Returns aWriter
object that can send character text to the client. TheWriter
uses the character encoding returned byServletResponse.getCharacterEncoding()
. If the response's character encoding has not been specified as described ingetCharacterEncoding
(i.e., the method just returns the default valueISO-8859-1
),getWriter
updates it toISO-8859-1
.- Returns:
- a
Writer
object that can return character data to the client - Throws:
UnsupportedEncodingException
- if the character encoding returned bygetCharacterEncoding
cannot be usedIllegalStateException
- if thegetOutputStream
method has already been called for this response objectIOException
- if an input or output exception occurred- See Also:
-
getPrintWriter
Returns aPrintWriter
object that can send character text to the client. ThePrintWriter
uses the character encoding returned byServletResponse.getCharacterEncoding()
. If the response's character encoding has not been specified as described ingetCharacterEncoding
(i.e., the method just returns the default valueISO-8859-1
),getWriter
updates it toISO-8859-1
.- Returns:
- a
PrintWriter
object that can return character data to the client - Throws:
UnsupportedEncodingException
- if the character encoding returned bygetCharacterEncoding
cannot be usedIllegalStateException
- if thegetOutputStream
method has already been called for this response objectIOException
- if an input or output exception occurred- See Also:
-
isResponseCommitted
Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.- Returns:
- a boolean indicating if the response has been committed
- See Also:
-
setContentType
Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example,>text/html;charset=UTF-8
. The response's character encoding is only set from the given content type if this method is called beforegetWriter
is called.- Parameters:
contentType
- aString
specifying the MIME type of the content- See Also:
-
getRequestLocale
Returns the preferredLocale
that the client will accept content in, based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns the default locale for the server.- Returns:
- the preferred
Locale
for the client - See Also:
-
getRequest
Returns the request object to use.- Returns:
- the request object to use
-
getResponse
Returns the response object to use.- Returns:
- the response object to use
-
isUserInRole
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 returnsfalse
.- Parameters:
role
- aString
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 - See Also:
-