package org.apache.wicket.protocol.http;
Implements responses over the HTTP protocol by holding an underlying HttpServletResponse object
and providing convenience methods for using that object. Convenience methods include methods
which: add a cookie, close the stream, encode a URL, redirect a request to another resource,
determine if a redirect has been issued, set the content type, set the locale and, most
importantly, write a String to the response output.
True if response is a redirect.
The underlying response object.
Is the request an ajax request?
Constructor for testing harness.
Package private constructor.
- Parameters:
httpServletResponse
The servlet response object
Add a cookie to the web response
Convenience method for clearing a cookie.
Returns the given url encoded.
- Parameters:
url
The URL to encode- Returns:
- The encoded url
Gets the wrapped http servlet response object.
- Returns:
- The wrapped http servlet response object
Whether this response is going to redirect the user agent.
- Returns:
- True if this response is going to redirect the user agent
CLIENTS SHOULD NEVER CALL THIS METHOD FOR DAY TO DAY USE!
Redirects to the given url. Implementations should encode the URL to make sure cookie-less
operation is supported in case clients forgot.
- Parameters:
url
The URL to redirect to
log.error("Unable to redirect to: " + url + ", HTTP Response has already been committed.");
log.info("Already redirecting to an url current one ignored: " + url); Set the content type on the response.
- Parameters:
mimeType
The mime type
Output stream encoding. If the deployment descriptor contains a locale-encoding-mapping-list
element, and that element provides a mapping for the given locale, that mapping is used.
Otherwise, the mapping from locale to character encoding is container dependent. Default is
ISO-8859-1.
Writes string to response output.
- Parameters:
string
The string to write
char[] array = new char[sb.length()];
Writes AppendingStringBuffer to response output.
- Parameters:
asb
The AppendingStringBuffer to write to the stream
Set a header to the date value in the servlet response stream.
Set a header to the string value in the servlet response stream.
Convenience method for setting the content-disposition:attachment header. This header is used
if the response should prompt the user to download it as a file instead of opening in a
browser.
- Parameters:
filename
file name of the attachment
setHeader("Content-Disposition", "attachment" + ((!Strings.isEmpty(filename)) ? ("; filename=\"" + filename + "\"") : "")); Is the request, which matches this response an ajax request.
- Returns:
- True if the request is an ajax request.
Set that the request which matches this response is an ajax request.
- Parameters:
ajax
True if the request is an ajax request.