Class HttpResponseFacade
java.lang.Object
org.eclipse.dirigible.api.v3.http.HttpResponseFacade
- All Implemented Interfaces:
IScriptingFacade
public class HttpResponseFacade extends Object implements IScriptingFacade
Java facade for working HttpServletResponse
-
Constructor Summary
Constructors Constructor Description HttpResponseFacade() -
Method Summary
Modifier and Type Method Description static voidaddCookie(String cookieJson)Adds a cookiestatic voidaddHeader(String name, String value)Adds the header.static voidclose()Closes the response output streamstatic booleancontainsHeader(String name)Checks if the response contains a header with the specified namestatic StringencodeRedirectURL(String url)Encode redirect URL.static StringencodeURL(String url)Encodes the specified URLstatic voidflush()Flushes the responsestatic StringgetCharacterEncoding()Returns the character encoding.static StringgetContentType()Returns the content type.static StringgetHeader(String name)Returns the value of the header with the specified namestatic StringgetHeaderNames()Returns the header names.static StringgetHeaders(String name)Returns the headers.static StringgetLocale()Returns the locale.static OutputStreamgetOutputStream()Open the output stream of the current servlet responsestatic javax.servlet.http.HttpServletResponsegetResponse()Returns the HttpServletResponse associated with the current thread contextstatic booleanisCommitted()Checks if the response is committed.static booleanisValid()Checks if there is a HttpServletResponse associated with the current thread contextstatic voidprint(double d)Prints the double primitive as textstatic voidprint(int i)Prints the int primitive as textstatic voidprint(Double d)Prints the double as textstatic voidprint(Integer i)Prints the integer as textstatic voidprint(Object o)Prints the object as textstatic voidprint(String text)Prints the textstatic voidprintln(double d)Prints the double primitive as text with a carriage returnstatic voidprintln(int i)Prints the int primitive as text with a carriage returnstatic voidprintln(Double d)Prints the Double as text with a carriage returnstatic voidprintln(Integer i)Prints the Integer as text with a carriage returnstatic voidprintln(Object o)Prints the object as text with a carriage returnstatic voidprintln(String text)Prints the text with a carriage returnstatic voidreset()Reset the bufferstatic voidsendError(int sc)Sends error.static voidsendError(int sc, String msg)Sends and error.static voidsendError(Double sc)Sends error.static voidsendError(Double sc, String msg)Sends error.static voidsendRedirect(String location)Sends redirect.static voidsetCharacterEncoding(String charset)Sets the character encoding.static voidsetContentLength(int len)Sets the content length.static voidsetContentLength(Double len)Sets the content length.static voidsetContentType(String contentType)Sets the content type.static voidsetHeader(String name, String value)Sets the header.static voidsetLocale(String language)Sets the locale.static voidsetLocale(String language, String country)Sets the locale.static voidsetLocale(String language, String country, String variant)Sets the locale.static voidsetStatus(int sc)Sets the status.static voidsetStatus(Double sc)Sets the status.static voidwrite(byte[] bytes)Writes the bytes to the output streamstatic voidwrite(String input)Writes the string bytes to the output stream
-
Constructor Details
-
HttpResponseFacade
public HttpResponseFacade()
-
-
Method Details
-
getResponse
public static final javax.servlet.http.HttpServletResponse getResponse()Returns the HttpServletResponse associated with the current thread context- Returns:
- the response
-
isValid
public static final boolean isValid()Checks if there is a HttpServletResponse associated with the current thread context- Returns:
- true, if there is a HttpServletResponse associated with the current thread context
-
print
Prints the text- Parameters:
text- the text
-
print
Prints the object as text- Parameters:
o- the object to be printed
-
print
public static final void print(int i)Prints the int primitive as text- Parameters:
i- the integer to be printed
-
print
public static final void print(double d)Prints the double primitive as text- Parameters:
d- the double to be printed
-
print
Prints the integer as text- Parameters:
i- the integer to be printed
-
print
Prints the double as text- Parameters:
d- the double to be printed
-
println
Prints the text with a carriage return- Parameters:
text- the text
-
println
Prints the object as text with a carriage return- Parameters:
o- the object
-
println
public static final void println(int i)Prints the int primitive as text with a carriage return- Parameters:
i- the int primitive
-
println
public static final void println(double d)Prints the double primitive as text with a carriage return- Parameters:
d- the double primitive
-
println
Prints the Integer as text with a carriage return- Parameters:
i- the integer
-
println
Prints the Double as text with a carriage return- Parameters:
d- the double
-
write
public static final void write(byte[] bytes)Writes the bytes to the output stream- Parameters:
bytes- the bytes
-
write
Writes the string bytes to the output stream- Parameters:
input- the input
-
isCommitted
public static boolean isCommitted()Checks if the response is committed.- Returns:
- true, if is committed
-
setContentType
Sets the content type.- Parameters:
contentType- the new content type
-
flush
public static final void flush()Flushes the response -
close
public static final void close()Closes the response output stream -
addCookie
Adds a cookie- Parameters:
cookieJson- the cookie in JSON format
-
containsHeader
Checks if the response contains a header with the specified name- Parameters:
name- the name- Returns:
- true, if the header has already been added
-
encodeURL
Encodes the specified URL- Parameters:
url- the url- Returns:
- the URL encoded
-
getCharacterEncoding
Returns the character encoding.- Returns:
- the character encoding
-
encodeRedirectURL
Encode redirect URL.- Parameters:
url- the url- Returns:
- the string
-
getContentType
Returns the content type.- Returns:
- the content type
-
sendError
Sends and error.- Parameters:
sc- the scmsg- the msg- Throws:
IOException- Signals that an I/O exception has occurred.
-
sendError
Sends error.- Parameters:
sc- the scmsg- the msg- Throws:
IOException- Signals that an I/O exception has occurred.
-
sendError
Sends error.- Parameters:
sc- the sc- Throws:
IOException- Signals that an I/O exception has occurred.
-
sendError
Sends error.- Parameters:
sc- the sc- Throws:
IOException- Signals that an I/O exception has occurred.
-
setCharacterEncoding
Sets the character encoding.- Parameters:
charset- the new character encoding
-
sendRedirect
Sends redirect.- Parameters:
location- the location- Throws:
IOException- Signals that an I/O exception has occurred.
-
setContentLength
public static final void setContentLength(int len)Sets the content length.- Parameters:
len- the new content length
-
setContentLength
Sets the content length.- Parameters:
len- the new content length
-
setHeader
Sets the header.- Parameters:
name- the namevalue- the value
-
addHeader
Adds the header.- Parameters:
name- the namevalue- the value
-
setStatus
public static final void setStatus(int sc)Sets the status.- Parameters:
sc- the new status
-
setStatus
Sets the status.- Parameters:
sc- the new status
-
reset
public static final void reset()Reset the buffer -
getHeader
Returns the value of the header with the specified name- Parameters:
name- the name- Returns:
- the header
-
setLocale
Sets the locale.- Parameters:
language- the new locale
-
setLocale
Sets the locale.- Parameters:
language- the languagecountry- the country
-
setLocale
Sets the locale.- Parameters:
language- the languagecountry- the countryvariant- the variant
-
getHeaders
Returns the headers.- Parameters:
name- the name- Returns:
- the headers
-
getHeaderNames
Returns the header names.- Returns:
- the header names
-
getLocale
Returns the locale.- Returns:
- the locale
-
getOutputStream
Open the output stream of the current servlet response- Returns:
- the created output stream
- Throws:
IOException- in case of failure in underlying layer
-