Package com.spec.web.expresso.message
Class HttpResponse
java.lang.Object
com.spec.web.expresso.message.HttpResponse
-
Constructor Summary
ConstructorsConstructorDescriptionHttpResponse(jakarta.servlet.http.HttpServletResponse resp) Constructs an instance of this class -
Method Summary
Modifier and TypeMethodDescriptionbooleanCloses the output stream.jakarta.servlet.http.HttpServletResponseReturns the httpservletresponse used internally by Expresso.Returns the output stream from response servlet.jakarta.servlet.http.HttpServletResponseresturns the raw http servlet responseResets the response objectResets the body of the responsesetContentTypeHeader(String contentType) Sets the content type headervoidsetCookies(jakarta.servlet.http.Cookie cookie, jakarta.servlet.http.Cookie... moreCookies) Sets a cookie that will be sent to the client.Sends html Note: Resets any data present in response objectsetResponseHeader(String name, String value) Sets the Http response headerssetStatusCode(Integer statusCode) Set the Http status code of the responsewriteResponse(String response) Set the http response body
-
Constructor Details
-
HttpResponse
public HttpResponse(jakarta.servlet.http.HttpServletResponse resp) Constructs an instance of this class- Parameters:
resp- HttpServletResponse to wrap
-
-
Method Details
-
writeResponse
Set the http response body- Specified by:
writeResponsein interfaceResponse- Parameters:
response- The response send to the client.- Returns:
- returns the current class instance for method chaining.
-
setStatusCode
Set the Http status code of the response- Specified by:
setStatusCodein interfaceResponse- Parameters:
statusCode- The status code of the message- Returns:
- returns the current class instance for method chaining.
-
setResponseHeader
Sets the Http response headers- Specified by:
setResponseHeaderin interfaceResponse- Parameters:
name- the name of the headervalue- the value of the header- Returns:
- returns the current class instance for method chaining.
-
setContentTypeHeader
Sets the content type header- Specified by:
setContentTypeHeaderin interfaceResponse- Parameters:
contentType- the content type the message body is made of- Returns:
- returns the current class instance for method chaining.
-
setHtml
Sends html Note: Resets any data present in response object -
resetResponse
Resets the response object- Specified by:
resetResponsein interfaceResponse- Returns:
- returns the current class instance for method chaining.
-
getRawHttpServletResponse
public jakarta.servlet.http.HttpServletResponse getRawHttpServletResponse()resturns the raw http servlet response- Returns:
- current http servlet response
-
resetResponseBody
Resets the body of the response- Specified by:
resetResponseBodyin interfaceResponse- Returns:
- returns the current class instance for method chaining.
-
getHttpServletResponse
public jakarta.servlet.http.HttpServletResponse getHttpServletResponse()Returns the httpservletresponse used internally by Expresso.- Returns:
- HttpServletResponse
-
getOutputStream
Returns the output stream from response servlet.- Specified by:
getOutputStreamin interfaceResponse- Returns:
- OutputStream
- Throws:
IOException- IOException
-
_closeOutputStream
public boolean _closeOutputStream()Closes the output stream. Returns true if successfull- Specified by:
_closeOutputStreamin interfaceResponse- Returns:
- Returns true if successfull.
-
setCookies
public void setCookies(jakarta.servlet.http.Cookie cookie, jakarta.servlet.http.Cookie... moreCookies) Sets a cookie that will be sent to the client.- Specified by:
setCookiesin interfaceResponse- Parameters:
cookie- Cookie instancemoreCookies- More cookies :)
-