Package helma.framework
Class ResponseBean
java.lang.Object
helma.framework.ResponseBean
- All Implemented Interfaces:
Serializable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Rollback the current database transaction and abort execution.void
addDateHeader
(String name, Date value) Proxy to HttpServletResponse.addDateHeader()void
Proxy to HttpServletResponse.addHeader()void
commit()
Commit changes made during the course of the current transaction and start a new onevoid
add HTML formatted debug messages to the end of the page.void
Add an item to this response's dependencies.void
digest()
Digest this response's dependencies to conditionally create a HTTP not-modified responsevoid
Write an object to the response buffer by converting it to a string and then HTML-encoding it.void
encodeForm
(Object obj) Write an object to the response buffer by converting it to a string and then encoding it for form/text area content use.void
Write an object to the response buffer by converting it to a string and then XML-encoding it.void
Write an object to the response buffer by converting it to a string and then HTML-formatting it.void
Internally forward the request to a different URLReturns the current response buffer as string.boolean
getCache()
Return the current cachability setting for this responseGet the current charset/encoding name for the responseGet the current content type name for the responsegetData()
Get the data map for the responsegetError()
Get the current error message for the response, if anygetETag()
Get the ETag for this responseGet the uncaught exception for the response, if anyGet the macro handlers map for the responseGet the Java stack trace of an uncaught exception.Get the last modified date for this responseGet the current message for the response, if setgetMeta()
Get the meta map for the responsegetRealm()
Get the HTTP authentication realm for the responseReturn the Javascript stack trace of an uncought exception.javax.servlet.http.HttpServletResponse
Returns the ServletResponse instance for this Response.Object[]
Get the skin search path for the responseint
Get the HTTP status code for this responsepop()
Pop a string buffer from the response object containing all the writes since the last pushBufferPops the current response buffer without converting it to a stringDeprecated.void
push()
Push a string buffer on the response object.Push a string buffer on the response object.pushBuffer
(StringBuffer buffer) Push a string buffer on the response object.void
Deprecated.void
Redirect the request to a different URLvoid
reset()
Reset the response object, clearing all content previously written to itvoid
Reset the response buffer, clearing all content previously written to itvoid
rollback()
Rollback the current transaction and start a new one.void
setCache
(boolean cache) Set true cachability setting for this responsevoid
setCharset
(String charset) Set the charset/encoding name for the responsevoid
setContentType
(String contentType) Set the content type for the responsevoid
Set a HTTP cookie with the name and value that is discarded when the HTTP client is closedvoid
Set a HTTP cookie with the name and value that is stored by the HTTP client for the given number of days.void
Set a HTTP cookie with the name and value that is only applied to the URLs matching the given path and is stored by the HTTP client for the given number of days.void
Set a HTTP cookie with the name and value that is only applied to the URLs matching the given path and is stored by the HTTP client for the given number of days.void
Set a HTTP cookie with the name and value that is only applied to the URLs matching the given path and is stored by the HTTP client for the given number of days.void
setCookie
(String key, String value, int days, String path, String domain, boolean isHttpOnly, boolean isSecure) Set a HTTP cookie with the name and value that is only applied to the URLs matching the given path and is stored by the HTTP client for the given number of days.void
setDateHeader
(String name, Date value) Proxy to HttpServletResponse.setDateHeader()void
Set the HTTP Etag for this responsevoid
Proxy to HttpServletResponse.setHeader()void
setLastModified
(Date date) Set the last modified date for this responsevoid
setMessage
(String message) Set the message property for the responsevoid
Set the HTTP authentication realm for the responsevoid
setSkinpath
(Object[] arr) Set the skin search path for the responsevoid
setStatus
(int status) Set the HTTP status code for this responsevoid
stop()
Immediately stop processing the current requesttoString()
Return a string representation for this objectvoid
unsetCookie
(String key) Unset a previously set HTTP cookie, causing it to be discarded immedialtely by the HTTP client.void
Directly write a string to the response buffer without any transformation.void
writeBinary
(byte[] bytes) Directly write a byte array to the response buffer without any transformation.void
writeln()
Write a platform dependent newline sequence to response buffer.void
Write string to response buffer and append a platform dependent newline sequence.
-
Constructor Details
-
ResponseBean
Creates a new ResponseBean object.- Parameters:
res
- the wrapped ResponseTrans
-
-
Method Details
-
encode
Write an object to the response buffer by converting it to a string and then HTML-encoding it.- Parameters:
obj
- the object to write to the response buffer
-
encodeXml
Write an object to the response buffer by converting it to a string and then XML-encoding it.- Parameters:
obj
- the object to write to the response buffer
-
encodeForm
Write an object to the response buffer by converting it to a string and then encoding it for form/text area content use.- Parameters:
obj
- the object to write to the response buffer
-
format
Write an object to the response buffer by converting it to a string and then HTML-formatting it.- Parameters:
obj
- the object to write to the response buffer
-
redirect
Redirect the request to a different URL- Parameters:
url
- the URL to redirect to- Throws:
RedirectException
- to immediately terminate the request
-
forward
Internally forward the request to a different URL- Parameters:
url
- the URL to forward to- Throws:
RedirectException
- to immediately terminate the request
-
stop
Immediately stop processing the current request- Throws:
RedirectException
- to immediately terminate the request
-
reset
public void reset()Reset the response object, clearing all content previously written to it -
resetBuffer
public void resetBuffer()Reset the response buffer, clearing all content previously written to it -
getServletResponse
public javax.servlet.http.HttpServletResponse getServletResponse()Returns the ServletResponse instance for this Response. Returns null for internal and XML-RPC requests.- Returns:
- the servlet response
-
setCookie
Set a HTTP cookie with the name and value that is discarded when the HTTP client is closed- Parameters:
key
- the cookie namevalue
- the cookie value
-
setCookie
Set a HTTP cookie with the name and value that is stored by the HTTP client for the given number of days. A days value of 0 means the cookie should be immediately discarded.- Parameters:
key
- the cookie namevalue
- the cookie valuedays
- number of days the cookie should be stored
-
setCookie
Set a HTTP cookie with the name and value that is only applied to the URLs matching the given path and is stored by the HTTP client for the given number of days. A days value of 0 means the cookie should be immediately discarded.- Parameters:
key
- the cookie namevalue
- the cookie valuedays
- number of days the cookie should be storedpath
- the URL path to apply the cookie to
-
setCookie
public void setCookie(String key, String value, int days, String path, String domain, boolean isHttpOnly) Set a HTTP cookie with the name and value that is only applied to the URLs matching the given path and is stored by the HTTP client for the given number of days. A days value of 0 means the cookie should be immediately discarded.- Parameters:
key
- the cookie namevalue
- the cookie valuedays
- number of days the cookie should be storedpath
- the URL path to apply the cookie todomain
- domainisHttpOnly
- marks the cookie as HttpOnly
-
setCookie
public void setCookie(String key, String value, int days, String path, String domain, boolean isHttpOnly, boolean isSecure) Set a HTTP cookie with the name and value that is only applied to the URLs matching the given path and is stored by the HTTP client for the given number of days. A days value of 0 means the cookie should be immediately discarded.- Parameters:
key
- the cookie namevalue
- the cookie valuedays
- number of days the cookie should be storedpath
- the URL path to apply the cookie todomain
- domainisHttpOnly
- marks the cookie as HttpOnlyisSecure
- limits the cookie to secure protocols
-
setCookie
Set a HTTP cookie with the name and value that is only applied to the URLs matching the given path and is stored by the HTTP client for the given number of days. A days value of 0 means the cookie should be immediately discarded.- Parameters:
key
- the cookie namevalue
- the cookie valuedays
- number of days the cookie should be storedpath
- the URL path to apply the cookie todomain
- domain
-
unsetCookie
Unset a previously set HTTP cookie, causing it to be discarded immedialtely by the HTTP client.- Parameters:
key
- the name of the cookie to be discarded
-
write
Directly write a string to the response buffer without any transformation.- Parameters:
str
- the string to write to the response buffer
-
writeln
Write string to response buffer and append a platform dependent newline sequence.- Parameters:
str
- the string to write to the response buffer
-
writeln
public void writeln()Write a platform dependent newline sequence to response buffer. -
writeBinary
public void writeBinary(byte[] bytes) Directly write a byte array to the response buffer without any transformation.- Parameters:
bytes
- the string to write to the response buffer
-
debug
add HTML formatted debug messages to the end of the page.- Parameters:
messages
- the list of messages
-
toString
Return a string representation for this object -
getCache
public boolean getCache()Return the current cachability setting for this response- Returns:
- true if the response may be cached by the HTTP client, false otherwise
-
setCache
public void setCache(boolean cache) Set true cachability setting for this response- Parameters:
cache
- true if the response may be cached by the HTTP client, false otherwise
-
getCharset
Get the current charset/encoding name for the response- Returns:
- The charset name
-
setCharset
Set the charset/encoding name for the response- Parameters:
charset
- The charset name
-
getContentType
Get the current content type name for the response- Returns:
- the content type
-
setContentType
Set the content type for the response- Parameters:
contentType
- The charset name
-
addHeader
Proxy to HttpServletResponse.addHeader()- Parameters:
name
- the header namevalue
- the header value
-
addDateHeader
Proxy to HttpServletResponse.addDateHeader()- Parameters:
name
- the header namevalue
- the header value
-
setHeader
Proxy to HttpServletResponse.setHeader()- Parameters:
name
- the header namevalue
- the header value
-
setDateHeader
Proxy to HttpServletResponse.setDateHeader()- Parameters:
name
- the header namevalue
- the header value
-
getData
Get the data map for the response- Returns:
- the data object
-
getHandlers
Get the macro handlers map for the response- Returns:
- the macro handlers map
-
getMeta
Get the meta map for the response- Returns:
- the meta map
-
getError
Get the current error message for the response, if any- Returns:
- the error message
-
getException
Get the uncaught exception for the response, if any- Returns:
- the uncaught exception
-
getScriptStack
Return the Javascript stack trace of an uncought exception.- Returns:
- the script stack trace of any uncaught exception or null.
-
getJavaStack
Get the Java stack trace of an uncaught exception.- Returns:
- the java stack trace of an uncaught exception or null.
-
getMessage
Get the current message for the response, if set- Returns:
- the message
-
setMessage
Set the message property for the response- Parameters:
message
- the message property
-
getRealm
Get the HTTP authentication realm for the response- Returns:
- the HTTP authentication realm
-
setRealm
Set the HTTP authentication realm for the response- Parameters:
realm
- the HTTP authentication realm
-
setSkinpath
Set the skin search path for the response- Parameters:
arr
- an array containing files or nodes containing skins
-
getSkinpath
Get the skin search path for the response- Returns:
- The array of files or nodes used to search for skins
-
getStatus
public int getStatus()Get the HTTP status code for this response- Returns:
- the HTTP status code
-
setStatus
public void setStatus(int status) Set the HTTP status code for this response- Parameters:
status
- the HTTP status code
-
getLastModified
Get the last modified date for this response- Returns:
- the last modified date
-
setLastModified
Set the last modified date for this response- Parameters:
date
- the last modified date
-
getETag
Get the ETag for this response- Returns:
- the HTTP etag
-
setETag
Set the HTTP Etag for this response- Parameters:
etag
- the HTTP ETag
-
dependsOn
Add an item to this response's dependencies. If no dependency has changed between requests, an HTTP not-modified response will be generated.- Parameters:
what
- a string item this response depends on
-
digest
public void digest()Digest this response's dependencies to conditionally create a HTTP not-modified response -
push
public void push()Push a string buffer on the response object. All further writes will be redirected to this buffer. -
pop
Pop a string buffer from the response object containing all the writes since the last pushBuffer- Returns:
- ...
-
pushStringBuffer
Deprecated.Old version for push() kept for compatibility -
popStringBuffer
Deprecated.Old version for pop() kept for compatibility- Returns:
- ...
-
pushBuffer
Push a string buffer on the response object. All further writes will be redirected to this buffer.- Parameters:
buffer
- the string buffer- Returns:
- the new stringBuffer
-
pushBuffer
Push a string buffer on the response object. All further writes will be redirected to this buffer.- Returns:
- the new stringBuffer
-
popBuffer
Pops the current response buffer without converting it to a string- Returns:
- the stringBuffer
-
getBuffer
Returns the current response buffer as string.- Returns:
- the response buffer as string
-
commit
Commit changes made during the course of the current transaction and start a new one- Throws:
Exception
- thrown if commit fails
-
rollback
Rollback the current transaction and start a new one.- Throws:
Exception
- thrown if rollback fails
-
abort
Rollback the current database transaction and abort execution. This has the same effect as calling rollback() and then stop().- Throws:
AbortException
- thrown to exit the the current execution
-