Package com.oorian.jakarta
Class JakartaHttpResponse
java.lang.Object
com.oorian.jakarta.JakartaHttpResponse
- All Implemented Interfaces:
OorianHttpResponse
Adapter that wraps a
HttpServletResponse to implement the
framework-agnostic OorianHttpResponse interface.
This class is used by the thin Jakarta library to bridge between the servlet container and the Oorian common library.
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Oorian Framework
- See Also:
-
Field Summary
Fields inherited from interface com.oorian.OorianHttpResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CREATED, SC_FORBIDDEN, SC_FOUND, SC_GONE, SC_INTERNAL_SERVER_ERROR, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_NO_CONTENT, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_SERVICE_UNAVAILABLE, SC_TEMPORARY_REDIRECT, SC_TOO_MANY_REQUESTS, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE -
Constructor Summary
ConstructorsConstructorDescriptionJakartaHttpResponse(jakarta.servlet.http.HttpServletResponse response) Creates a new adapter wrapping the given servlet response. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(OorianCookie cookie) Adds a cookie to the response.voidAdds a response header without replacing existing values.booleancontainsHeader(String name) Returns whether the response contains the specified header.voidForces any content in the buffer to be written to the client.jakarta.servlet.http.HttpServletResponseReturns the underlying Jakarta servlet response.Returns the output stream for writing binary response data.intReturns the current HTTP status code of this response.Returns a PrintWriter for writing character response data.booleanReturns whether the response has been committed.voidSends an error response with the specified status code and message.voidsendRedirect(String url) Sends a temporary redirect response to the specified URL.voidsetCharacterEncoding(String charset) Sets the character encoding of the response.voidsetContentLength(int len) Sets the content length of the response body.voidsetContentType(String type) Sets the content type of the response.voidSets a response header, replacing any existing values.voidsetStatus(int sc) Sets the HTTP status code of the response.
-
Constructor Details
-
JakartaHttpResponse
public JakartaHttpResponse(jakarta.servlet.http.HttpServletResponse response) Creates a new adapter wrapping the given servlet response.- Parameters:
response- The Jakarta servlet response to wrap.
-
-
Method Details
-
setContentType
Description copied from interface:OorianHttpResponseSets the content type of the response.- Specified by:
setContentTypein interfaceOorianHttpResponse- Parameters:
type- the MIME content type
-
setCharacterEncoding
Description copied from interface:OorianHttpResponseSets the character encoding of the response.- Specified by:
setCharacterEncodingin interfaceOorianHttpResponse- Parameters:
charset- the character encoding name
-
setContentLength
public void setContentLength(int len) Description copied from interface:OorianHttpResponseSets the content length of the response body.- Specified by:
setContentLengthin interfaceOorianHttpResponse- Parameters:
len- the content length in bytes
-
getOutputStream
Description copied from interface:OorianHttpResponseReturns the output stream for writing binary response data.- Specified by:
getOutputStreamin interfaceOorianHttpResponse- Returns:
- the output stream
- Throws:
IOException- if an I/O error occurs
-
getWriter
Description copied from interface:OorianHttpResponseReturns a PrintWriter for writing character response data.- Specified by:
getWriterin interfaceOorianHttpResponse- Returns:
- the print writer
- Throws:
IOException- if an I/O error occurs
-
setHeader
Description copied from interface:OorianHttpResponseSets a response header, replacing any existing values.- Specified by:
setHeaderin interfaceOorianHttpResponse- Parameters:
name- the header namevalue- the header value
-
addHeader
Description copied from interface:OorianHttpResponseAdds a response header without replacing existing values.- Specified by:
addHeaderin interfaceOorianHttpResponse- Parameters:
name- the header namevalue- the header value
-
isCommitted
public boolean isCommitted()Description copied from interface:OorianHttpResponseReturns whether the response has been committed.- Specified by:
isCommittedin interfaceOorianHttpResponse- Returns:
- true if the response has been committed
-
sendError
Description copied from interface:OorianHttpResponseSends an error response with the specified status code and message.- Specified by:
sendErrorin interfaceOorianHttpResponse- Parameters:
sc- the HTTP status codemsg- the error message- Throws:
IOException- if an I/O error occurs
-
setStatus
public void setStatus(int sc) Description copied from interface:OorianHttpResponseSets the HTTP status code of the response.- Specified by:
setStatusin interfaceOorianHttpResponse- Parameters:
sc- the status code
-
sendRedirect
Description copied from interface:OorianHttpResponseSends a temporary redirect response to the specified URL.- Specified by:
sendRedirectin interfaceOorianHttpResponse- Parameters:
url- the redirect URL- Throws:
IOException- if an I/O error occurs
-
addCookie
Description copied from interface:OorianHttpResponseAdds a cookie to the response.- Specified by:
addCookiein interfaceOorianHttpResponse- Parameters:
cookie- the cookie to add
-
getStatus
public int getStatus()Description copied from interface:OorianHttpResponseReturns the current HTTP status code of this response.- Specified by:
getStatusin interfaceOorianHttpResponse- Returns:
- the status code
-
containsHeader
Description copied from interface:OorianHttpResponseReturns whether the response contains the specified header.- Specified by:
containsHeaderin interfaceOorianHttpResponse- Parameters:
name- the header name- Returns:
- true if the header has been set
-
flushBuffer
Description copied from interface:OorianHttpResponseForces any content in the buffer to be written to the client.- Specified by:
flushBufferin interfaceOorianHttpResponse- Throws:
IOException- if an I/O error occurs
-
getDelegate
public jakarta.servlet.http.HttpServletResponse getDelegate()Returns the underlying Jakarta servlet response.- Returns:
- The wrapped
HttpServletResponse.
-