public abstract class WebResponse extends Response
Modifier and Type | Class and Description |
---|---|
static class |
WebResponse.CacheScope
caching scope for data
Unless the data is confidential, session-specific or user-specific the general advice is to
prefer value
PUBLIC for best network performance. |
Modifier and Type | Field and Description |
---|---|
static Duration |
MAX_CACHE_DURATION
Recommended value for cache duration
|
Constructor and Description |
---|
WebResponse() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addCookie(javax.servlet.http.Cookie cookie)
Add a cookie to the web response
|
abstract void |
addHeader(String name,
String value)
Add a value to the servlet response stream.
|
abstract void |
clearCookie(javax.servlet.http.Cookie cookie)
Convenience method for clearing a cookie.
|
void |
disableCaching()
Make this response non-cacheable
|
void |
enableCaching(Duration duration,
WebResponse.CacheScope scope)
Make this response cacheable
when trying to enable caching for web pages check this out: WICKET-4357
|
abstract String |
encodeRedirectURL(CharSequence url)
Encodes urls used to redirect.
|
abstract void |
flush()
Flushes the response.
|
abstract boolean |
isRedirect() |
abstract void |
sendError(int sc,
String msg)
Send error status code with optional message.
|
abstract void |
sendRedirect(String url)
Redirects the response to specified URL.
|
void |
setAcceptRange(String acceptRange)
Sets the accept range (e.g.
|
void |
setAttachmentHeader(String filename)
Convenience method for setting the content-disposition:attachment header.
|
abstract void |
setContentLength(long length)
Set the content length on the response, if appropriate in the subclass.
|
void |
setContentRange(String contentRange)
Sets the content range of the response.
|
abstract void |
setContentType(String mimeType)
Set the content type on the response, if appropriate in the subclass.
|
abstract void |
setDateHeader(String name,
Time date)
Set a header to the date value in the servlet response stream.
|
abstract void |
setHeader(String name,
String value)
Set a header to the string value in the servlet response stream.
|
void |
setInlineHeader(String filename)
Convenience method for setting the content-disposition:inline header.
|
void |
setLastModifiedTime(Time time)
Set the contents last modified time, if appropriate in the subclass.
|
abstract void |
setStatus(int sc)
Sets the status code for this response.
|
close, encodeURL, getContainerResponse, getOutputStream, reset, write, write, write
public static final Duration MAX_CACHE_DURATION
public abstract void addCookie(javax.servlet.http.Cookie cookie)
cookie
- public abstract void clearCookie(javax.servlet.http.Cookie cookie)
cookie
- The cookie to setaddCookie(Cookie)
public abstract void setHeader(String name, String value)
name
- value
- public abstract void addHeader(String name, String value)
name
- value
- public abstract void setDateHeader(String name, Time date)
name
- date
- public abstract void setContentLength(long length)
length
- The length of the contentpublic abstract void setContentType(String mimeType)
mimeType
- The mime typepublic void setContentRange(String contentRange)
contentRange
- the content rangepublic void setAcceptRange(String acceptRange)
acceptRange
- the accept range header informationpublic void setLastModifiedTime(Time time)
time
- The last modified timepublic void setAttachmentHeader(String filename)
The file name will be encoded
filename
- file name of the attachmentpublic void setInlineHeader(String filename)
The file name will be encoded
filename
- file name of the attachmentpublic abstract void setStatus(int sc)
sc
- status codepublic abstract void sendError(int sc, String msg)
sc
- msg
- IOException
public abstract String encodeRedirectURL(CharSequence url)
Response.encodeURL(CharSequence)
.url
- public abstract void sendRedirect(String url)
url
parameters
through the encodeRedirectURL(CharSequence)
method.url
- public abstract boolean isRedirect()
true
is sendRedirect(String)
was called, false
otherwise.public abstract void flush()
public void disableCaching()
public void enableCaching(Duration duration, WebResponse.CacheScope scope)
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 responseMAX_CACHE_DURATION
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.