public interface HstResponse
extends javax.servlet.http.HttpServletResponse
HstResponse
defines the interface to assist a
HstComponent in creating and sending a response to the client. The HstComponent
container uses specialized versions of this interface when invoking a
HstComponent.
The HstComponent container creates these objects and passes them as arguments to
the HstComponent's doAction, doBeforeRender
and doBeforeServeResource
methods.SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
Modifier and Type | Method and Description |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response.
|
void |
addEpilogue(Comment comment)
Add an epilogue comment, which gets rendered at the end of the render window.
|
void |
addHeadElement(Element element,
String keyHint)
Adds an header element property to the response.
|
void |
addPreamble(Comment comment)
Add a preamble comment node, which gets rendered at the beginning of the render
window.
|
void |
addPreamble(Element element)
Preamble
Node s are written before the rest of the content of this HstResponseState . |
void |
addProcessedHeadElement(Element headElement) |
boolean |
containsHeadElement(String keyHint)
Asks if a property exists already or not.
|
HstURL |
createActionURL()
Creates a HST Action URL targeting the HstComponent.
|
Comment |
createComment(String comment)
Creates a comment element
|
HstURL |
createComponentRenderingURL()
Creates a HST component rendering URL targeting a specific HstComponent
|
Element |
createElement(String tagName)
Creates an element of the type specified to be used in the
addPreamble(org.w3c.dom.Element) method. |
HstURL |
createNavigationalURL(String pathInfo)
Creates a HST Navigational Render URL
|
HstURL |
createRenderURL()
Creates a HST Render URL targeting the HstComponent.
|
HstURL |
createResourceURL()
Creates a HST Resource URL targeting the current HstComponent.
|
HstURL |
createResourceURL(String referenceNamespace)
Creates a HST Resource URL targeting the HstComponent indicated by referenceNamespace.
|
void |
flushChildContent(String name)
Flushes the buffer of child window.
|
void |
flushChildContent(String name,
Writer writer)
Flushes the child window, and writes its content to the
Writer . |
void |
forward(String pathInfo)
Forwards the page request to pathInfo.
|
List<String> |
getChildContentNames()
Returns the flushable child content window names.
|
List<Element> |
getHeadElements()
Retrieves header element list.
|
String |
getNamespace()
The value returned by this method should be prefixed or appended to elements,
such as JavaScript variables or function names, to ensure they are unique
in the context of the HST-managed page.
|
Element |
getWrapperElement()
Returns the wrapper element for the rendered content
|
boolean |
isRendererSkipped()
For single /subtree component rendering mode that has
HstComponentInfo.isStandalone() equal to false , this
check can be used whether some HstComponent won't get its renderer called. |
void |
sendError(int sc)
Sends an error response to the client using the specified status.
|
void |
sendError(int sc,
String msg)
Sends an error response to the client using the specified status.
|
void |
sendRedirect(String location)
Sends a temporary redirect response to the client using the specified redirect location URL.
|
void |
setRenderParameter(String key,
String value)
Sets a String parameter for the rendering phase.
|
void |
setRenderParameter(String key,
String[] values)
Sets a String parameter for the rendering phase.
|
void |
setRenderParameters(Map<String,String[]> parameters)
Sets a parameter map for the render request.
|
void |
setRenderPath(String renderPath)
Sets the renderPath dynamically.
|
void |
setServeResourcePath(String serveResourcePath)
Sets the serveResourcePath dynamically.
|
void |
setStatus(int sc)
Sets the status code for this response.
|
void |
setWrapperElement(Element element)
Sets wrapper element for the rendered content
|
HstURL createRenderURL()
HstURL createNavigationalURL(String pathInfo)
pathInfo
- the path to be navigatedHstURL createActionURL()
HstURL createResourceURL()
HstURL createResourceURL(String referenceNamespace)
referenceNamespace
- HstURL createComponentRenderingURL()
String getNamespace()
void setRenderParameter(String key, String value)
key
- key of the render parametervalue
- value of the render parametervoid setRenderParameter(String key, String[] values)
key
- key of the render parametervalues
- values of the render parametersvoid setRenderParameters(Map<String,String[]> parameters)
parameters
- Element createElement(String tagName)
addPreamble(org.w3c.dom.Element)
method.tagName
- the tag name of the elementComment createComment(String comment)
comment
- the comment textvoid addHeadElement(Element element, String keyHint)
element
- keyHint
- List<Element> getHeadElements()
boolean containsHeadElement(String keyHint)
keyHint
- void addProcessedHeadElement(Element headElement)
void setRenderPath(String renderPath)
HstComponent.doBeforeRender(HstRequest, HstResponse)
method.renderPath
- void setServeResourcePath(String serveResourcePath)
HstComponent.doBeforeServeResource(HstRequest, HstResponse)
method.serveResourcePath
- void flushChildContent(String name) throws IOException
Note: the child content can be flushed only once. If it is already flushed, then the next invocations will not make any effect.
name
- the name of the child windowIOException
void flushChildContent(String name, Writer writer) throws IOException
Writer
. Note that not everything that gets
flushed ends up in the writer
, for example head contributions not.name
- the name of the child window to flushwriter
- the Writer
the content gets flushed toIOException
List<String> getChildContentNames()
void sendRedirect(String location) throws IOException
In either HstComponent.doAction(HstRequest, HstResponse)
or HstComponent.doBeforeRender(HstRequest, HstResponse)
,
the invocation on this method could be effective.
If the invocation on this method is done in other methods,
the invocation will be just ignored with no operation.
sendRedirect
in interface javax.servlet.http.HttpServletResponse
location
- the redirect location URLIOException
HttpServletResponse.sendRedirect(String)
void sendError(int sc, String msg) throws IOException
Only in HstComponent.doAction(HstRequest, HstResponse)
,
HstComponent.doBeforeRender(HstRequest, HstResponse)
or HstComponent.doBeforeServeResource(HstRequest, HstResponse)
,
the invocation on this method will be effective.
If the invocation on this method is done in a view page during render phase,
the invocation will be just ignored with no operation.
sendError
in interface javax.servlet.http.HttpServletResponse
sc
- the error status codemsg
- the descriptive messageIOException
- If the response was committedvoid sendError(int sc) throws IOException
Only in HstComponent.doAction(HstRequest, HstResponse)
,
HstComponent.doBeforeRender(HstRequest, HstResponse)
or HstComponent.doBeforeServeResource(HstRequest, HstResponse)
,
the invocation on this method will be effective.
If the invocation on this method is done in a view page during render phase,
the invocation will be just ignored with no operation.
sendError
in interface javax.servlet.http.HttpServletResponse
sc
- the error status codeIOException
- If the response was committedvoid setStatus(int sc)
If there are multiple HST components to invoke this method, then the last invocation will be applied.
setStatus
in interface javax.servlet.http.HttpServletResponse
void forward(String pathInfo) throws IOException
Only in HstComponent.doBeforeRender(HstRequest, HstResponse)
,
the invocation on this method will be effective.
If the invocation on this method is done in a view page during render phase,
the invocation will be just ignored with no operation.
pathInfo
- the path info to forward. It should start with a "/" and is relative to the root of your hst sitemapIOException
- If the response was committedvoid addCookie(javax.servlet.http.Cookie cookie)
Note: Please be sure to set cookie path before adding cookie for safety like the following example:
Cookie cookie = new Cookie("testcookie", "testvalue");
cookie.setPath("/");
response.addCookie(cookie);
Sometimes, a user agent could not accept cookies when the response triggers page redirection with Set-Cookie header. It's possibly because it regards the state as an unverifiable transaction for some reason. By setting path, the cookie can be specified more as a subset of the current domain, and this makes sure that the cookie accepted safely by the user agent.
addCookie
in interface javax.servlet.http.HttpServletResponse
cookie
- the Cookie to return to the clientvoid setWrapperElement(Element element)
element
- Element getWrapperElement()
void addPreamble(Comment comment)
comment
- the comment nodevoid addPreamble(Element element)
Node
s are written before the rest of the content of this HstResponseState
. Note that
from this element
only the element, attributes and text of the element
are printed, and *not*
any descendant @link org.w3c.dom.Node}s of element
element
- the element that is a preamblevoid addEpilogue(Comment comment)
comment
- the comment nodeboolean isRendererSkipped()
HstComponentInfo.isStandalone()
equal to false
, this
check can be used whether some HstComponent
won't get its renderer called. In other words, this is for performance optimization
to short-circuit the doBeforeRender for components that won't get rendered any way.true
when for this HstResponse
the renderer won't be invokedCopyright © 2008–2017 Hippo B.V. (http://www.onehippo.com). All rights reserved.