Package com.aspectran.web.adapter
Class HttpServletResponseAdapter
java.lang.Object
com.aspectran.core.adapter.AbstractResponseAdapter
com.aspectran.web.adapter.HttpServletResponseAdapter
- All Implemented Interfaces:
ResponseAdapter
Adapt
HttpServletResponse
to Core ResponseAdapter
.- Since:
- 2011. 3. 13.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionHttpServletResponseAdapter
(jakarta.servlet.http.HttpServletResponse response, Activity activity) Instantiates a new HttpServletResponseAdapter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the given single header value to the current list of values for the given header.boolean
containsHeader
(String name) Returns a boolean indicating whether the named response header has already been set.void
flush()
Forces any content in the buffer to be written to the client.Returns the content type used for the MIME body sent in this response.Returns the name of the character encoding (MIME charset) used for the body sent in this response.Returns the value of the response header with the given name.Returns the names of the headers of this response.getHeaders
(String name) Returns the values of the response header with the given name.Returns aOutputStream
suitable for writing binary data in the response.int
Returns the status code.Returns aWriter
object that can send character text to the client.static String
makeRedirectPath
(RedirectRule redirectRule, Activity activity) redirect
(RedirectRule redirectRule) Redirects a client to a new URL.void
Sends a temporary redirect response to the client using the specified redirect location.void
setContentType
(String contentType) Sets the content type of the response being sent to the client, if the response has not been committed yet.void
setEncoding
(String encoding) Sets the character encoding of the response being sent to the client.void
Set the given single header value under the given header name.void
setStatus
(int status) Sets the status code.Methods inherited from class com.aspectran.core.adapter.AbstractResponseAdapter
getAdaptee
-
Field Details
-
PROXY_PROTOCOL_AWARE_SETTING_NAME
- See Also:
-
-
Constructor Details
-
HttpServletResponseAdapter
public HttpServletResponseAdapter(jakarta.servlet.http.HttpServletResponse response, Activity activity) Instantiates a new HttpServletResponseAdapter.- Parameters:
response
- the HTTP responseactivity
- the activity
-
-
Method Details
-
getHeader
Description copied from interface:ResponseAdapter
Returns the value of the response header with the given name.If a response header with the given name exists and contains multiple values, the value that was added first will be returned.
- Parameters:
name
- the name of the response header whose value to return- Returns:
- the value of the response header with the given name,
or
null
if no header with the given name has been set on this response
-
getHeaders
Description copied from interface:ResponseAdapter
Returns the values of the response header with the given name.- Parameters:
name
- the name of the response header whose values to return- Returns:
- a (possibly empty)
Collection
of the values of the response header with the given name
-
getHeaderNames
Description copied from interface:ResponseAdapter
Returns the names of the headers of this response.- Returns:
- a (possibly empty)
Collection
of the names of the headers of this response
-
containsHeader
Description copied from interface:ResponseAdapter
Returns a boolean indicating whether the named response header has already been set.- Parameters:
name
- the header name- Returns:
true
if the named response header has already been set;false
otherwise
-
setHeader
Description copied from interface:ResponseAdapter
Set the given single header value under the given header name. If the header had already been set, the new value overwrites the previous one.- Parameters:
name
- the header namevalue
- the header value to set
-
addHeader
Description copied from interface:ResponseAdapter
Add the given single header value to the current list of values for the given header.- Parameters:
name
- the header namevalue
- the header value to be added
-
getEncoding
Description copied from interface:ResponseAdapter
Returns the name of the character encoding (MIME charset) used for the body sent in this response.- Returns:
- a
String
specifying the name of the character encoding, for example, UTF-8
-
setEncoding
Description copied from interface:ResponseAdapter
Sets the character encoding of the response being sent to the client.- Parameters:
encoding
- aString
specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)- Throws:
UnsupportedEncodingException
- if character encoding is not supported
-
getContentType
Description copied from interface:ResponseAdapter
Returns the content type used for the MIME body sent in this response.- Returns:
- a
String
specifying the content type, for example,text/html
, or null
-
setContentType
Description copied from interface:ResponseAdapter
Sets the content type of the response being sent to the client, if the response has not been committed yet.- Parameters:
contentType
- aString
specifying the MIME type of the content
-
getOutputStream
Description copied from interface:ResponseAdapter
Returns aOutputStream
suitable for writing binary data in the response.- Returns:
- a
OutputStream
for writing binary data - Throws:
IOException
- if an input or output exception occurs
-
getWriter
Description copied from interface:ResponseAdapter
Returns aWriter
object that can send character text to the client.- Returns:
- a
Writer
object that can return character data to the client - Throws:
IOException
- if an input or output exception occurs
-
flush
Description copied from interface:ResponseAdapter
Forces any content in the buffer to be written to the client.- Throws:
IOException
- if an input or output exception occurs
-
redirect
Description copied from interface:ResponseAdapter
Sends a temporary redirect response to the client using the specified redirect location.- Parameters:
location
- the redirect location- Throws:
IOException
- if an input or output exception occurs
-
redirect
Description copied from interface:ResponseAdapter
Redirects a client to a new URL.- Parameters:
redirectRule
- the redirect rule- Returns:
- the redirect path
- Throws:
IOException
- if an input or output exception occurs
-
getStatus
public int getStatus()Description copied from interface:ResponseAdapter
Returns the status code.- Returns:
- the status
-
setStatus
public void setStatus(int status) Description copied from interface:ResponseAdapter
Sets the status code.- Parameters:
status
- the status code
-
makeRedirectPath
@NonNull public static String makeRedirectPath(RedirectRule redirectRule, Activity activity) throws IOException - Throws:
IOException
-