java.lang.Object
org.apache.wicket.request.Response
org.apache.wicket.request.http.WebResponse
Base class for web-related responses.
- Author:
- Matej Knopp
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddCookie(jakarta.servlet.http.Cookie cookie) Add a cookie to the web responseabstract voidAdd a value to the servlet response stream.abstract voidclearCookie(jakarta.servlet.http.Cookie cookie) Convenience method for clearing a cookie.voidMake this response non-cacheablevoidenableCaching(Duration duration, WebResponse.CacheScope scope) Make this response cacheableabstract StringEncodes urls used to redirect.abstract voidflush()Flushes the response.abstract booleanIndicates if the response supports setting headers.abstract booleanabstract voidSend error status code with optional message.abstract voidsendRedirect(String url) Redirects the response to specified URL.voidsetAcceptRange(String acceptRange) Sets the accept range (e.g. bytes)voidsetAttachmentHeader(String filename) Convenience method for setting the content-disposition:attachment header.abstract voidsetContentLength(long length) Set the content length on the response, if appropriate in the subclass.voidsetContentRange(String contentRange) Sets the content range of the response.abstract voidsetContentType(String mimeType) Set the content type on the response, if appropriate in the subclass.abstract voidsetDateHeader(String name, Instant date) Set a header to the date value in the servlet response stream.abstract voidSet a header to the string value in the servlet response stream.voidsetInlineHeader(String filename) Convenience method for setting the content-disposition:inline header.voidsetLastModifiedTime(Instant time) Set the contents last modified time, if appropriate in the subclass.abstract voidsetStatus(int sc) Sets the status code for this response.Methods inherited from class org.apache.wicket.request.Response
close, encodeURL, getContainerResponse, getOutputStream, reset, write, write, write
-
Field Details
-
MAX_CACHE_DURATION
Recommended value for cache duration
-
-
Constructor Details
-
WebResponse
public WebResponse()
-
-
Method Details
-
addCookie
Add a cookie to the web response- Parameters:
cookie-
-
clearCookie
Convenience method for clearing a cookie.- Parameters:
cookie- The cookie to set- See Also:
-
isHeaderSupported
Indicates if the response supports setting headers. When this method returns false,setHeader(String, String)and its variations will thrown anUnsupportedOperationException.- Returns:
- True when this
WebResponsesupports setting headers.
-
setHeader
Set a header to the string value in the servlet response stream.- Parameters:
name-value-
-
addHeader
Add a value to the servlet response stream.- Parameters:
name-value-
-
setDateHeader
Set a header to the date value in the servlet response stream.- Parameters:
name-date-
-
setContentLength
Set the content length on the response, if appropriate in the subclass. This default implementation does nothing.- Parameters:
length- The length of the content
-
setContentType
Set the content type on the response, if appropriate in the subclass. This default implementation does nothing.- Parameters:
mimeType- The mime type
-
setContentRange
Sets the content range of the response. If no content range is set the client assumes the whole content. Please note that if the content range is set, the content length, the status code and the accept range must be set right, too.- Parameters:
contentRange- the content range
-
setAcceptRange
Sets the accept range (e.g. bytes)- Parameters:
acceptRange- the accept range header information
-
setLastModifiedTime
Set the contents last modified time, if appropriate in the subclass.- Parameters:
time- The last modified time
-
setAttachmentHeader
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.The file name will be encoded
- Parameters:
filename- file name of the attachment
-
setInlineHeader
Convenience method for setting the content-disposition:inline header. This header is used if the response should be shown embedded in browser window while having custom file name when user saves the response. browser.The file name will be encoded
- Parameters:
filename- file name of the attachment
-
setStatus
Sets the status code for this response.- Parameters:
sc- status code
-
sendError
Send error status code with optional message.- Parameters:
sc-msg-
-
encodeRedirectURL
Encodes urls used to redirect. Sometimes rules for encoding URLs for redirecting differ from encoding URLs for links, so this method is broken out away formResponse.encodeURL(CharSequence).- Parameters:
url-- Returns:
- encoded URL
-
sendRedirect
Redirects the response to specified URL. The implementation is responsible for properly encoding the URL. Implementations of this method should run passed inurlparameters through theencodeRedirectURL(CharSequence)method.- Parameters:
url-
-
isRedirect
- Returns:
trueissendRedirect(String)was called,falseotherwise.
-
flush
Flushes the response. -
disableCaching
Make this response non-cacheable -
enableCaching
Make this response cacheable when trying to enable caching for web pages check this out: WICKET-4357- Parameters:
duration- maximum duration before the response must be invalidated by any caches. It should not exceed one year, based on RFC-2616.scope- controls which caches are allowed to cache the response- See Also:
-