|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.ServletResponseWrapper
javax.servlet.http.HttpServletResponseWrapper
org.hippoecm.hst.core.component.HstResponseImpl
public class HstResponseImpl
Factory implementation for creating HTTP Response Wrappers
Field Summary | |
---|---|
protected HstComponentWindow |
componentWindow
|
protected String |
redirectLocation
|
protected Map<String,String[]> |
renderParameters
|
protected String |
renderPath
|
protected javax.servlet.http.HttpServletRequest |
request
|
protected HstRequestContext |
requestContext
|
protected javax.servlet.http.HttpServletResponse |
response
|
protected HstResponseState |
responseState
|
protected HstResponse |
topParentHstResponse
|
Fields inherited from interface javax.servlet.http.HttpServletResponse |
---|
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 |
Constructor Summary | |
---|---|
HstResponseImpl(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
HstRequestContext requestContext,
HstComponentWindow componentWindow,
HstResponseState responseState,
HstResponse topParentHstResponse)
|
Method Summary | |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response. |
void |
addDateHeader(String name,
long date)
|
void |
addHeadElement(Element element,
String keyHint)
Adds an header element property to the response. |
void |
addHeader(String name,
String value)
|
void |
addIntHeader(String name,
int value)
|
void |
addPreamble(Comment comment)
Add a preamble comment node, which gets rendered at the beginning of the render window. |
boolean |
containsHeadElement(String keyHint)
Asks if a property exists already or not. |
boolean |
containsHeader(String name)
|
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 #addProperty(String, 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. |
String |
encodeRedirectUrl(String url)
|
String |
encodeRedirectURL(String url)
|
String |
encodeUrl(String url)
|
String |
encodeURL(String url)
|
void |
flushBuffer()
|
void |
flushChildContent(String name)
Flushes the buffer of child window. |
void |
forward(String pathInfo)
Forwards the page request to pathInfo. |
int |
getBufferSize()
|
String |
getCharacterEncoding()
|
List<String> |
getChildContentNames()
Returns the flushable child content window names. |
String |
getContentType()
|
List<Element> |
getHeadElements()
Retrieves header element list. |
Locale |
getLocale()
|
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. |
javax.servlet.ServletOutputStream |
getOutputStream()
|
String |
getRedirectLocation()
|
Map<String,String[]> |
getRenderParameters()
|
String |
getRenderPath()
|
Element |
getWrapperElement()
Returns the wrapper element for the rendered content |
PrintWriter |
getWriter()
|
boolean |
isCommitted()
|
boolean |
isRendererSkipped()
A normal HstResponseImpl never gets its renderer skipped |
void |
reset()
|
void |
resetBuffer()
|
void |
sendError(int errorCode)
Sends an error response to the client using the specified status. |
void |
sendError(int errorCode,
String errorMessage)
Sends an error response to the client using the specified status. |
void |
sendRedirect(String redirectLocation)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
setBufferSize(int size)
|
void |
setCharacterEncoding(String charset)
|
void |
setContentLength(int len)
|
void |
setContentType(String type)
|
void |
setDateHeader(String name,
long date)
|
void |
setHeader(String name,
String value)
|
void |
setIntHeader(String name,
int value)
|
void |
setLocale(Locale locale)
|
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 |
setResponse(javax.servlet.http.HttpServletResponse response)
|
void |
setServeResourcePath(String serveResourcePath)
Sets the serveResourcePath dynamically. |
void |
setStatus(int statusCode)
Sets the status code for this response. |
void |
setStatus(int statusCode,
String message)
|
void |
setWrapperElement(Element element)
Sets wrapper element for the rendered content |
Methods inherited from class javax.servlet.ServletResponseWrapper |
---|
getResponse, setResponse |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpServletResponse response
protected HstRequestContext requestContext
protected HstComponentWindow componentWindow
protected HstResponseState responseState
protected String redirectLocation
protected Map<String,String[]> renderParameters
protected HstResponse topParentHstResponse
protected String renderPath
Constructor Detail |
---|
public HstResponseImpl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, HstRequestContext requestContext, HstComponentWindow componentWindow, HstResponseState responseState, HstResponse topParentHstResponse)
Method Detail |
---|
public HstURL createRenderURL()
HstResponse
createRenderURL
in interface HstResponse
public HstURL createNavigationalURL(String pathInfo)
HstResponse
createNavigationalURL
in interface HstResponse
pathInfo
- the path to be navigated
public HstURL createComponentRenderingURL()
HstResponse
createComponentRenderingURL
in interface HstResponse
public HstURL createActionURL()
HstResponse
createActionURL
in interface HstResponse
public HstURL createResourceURL()
HstResponse
createResourceURL
in interface HstResponse
public HstURL createResourceURL(String referenceNamespace)
HstResponse
createResourceURL
in interface HstResponse
public String getNamespace()
HstResponse
getNamespace
in interface HstResponse
public void setResponse(javax.servlet.http.HttpServletResponse response)
public String getRedirectLocation()
public void addCookie(javax.servlet.http.Cookie cookie)
HstResponse
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
addCookie
in interface HstResponse
addCookie
in class javax.servlet.http.HttpServletResponseWrapper
cookie
- the Cookie to return to the clientpublic void addDateHeader(String name, long date)
addDateHeader
in interface javax.servlet.http.HttpServletResponse
addDateHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void addHeader(String name, String value)
addHeader
in interface javax.servlet.http.HttpServletResponse
addHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void addIntHeader(String name, int value)
addIntHeader
in interface javax.servlet.http.HttpServletResponse
addIntHeader
in class javax.servlet.http.HttpServletResponseWrapper
public boolean containsHeader(String name)
containsHeader
in interface javax.servlet.http.HttpServletResponse
containsHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void flushBuffer() throws IOException
flushBuffer
in interface javax.servlet.ServletResponse
flushBuffer
in class javax.servlet.ServletResponseWrapper
IOException
public int getBufferSize()
getBufferSize
in interface javax.servlet.ServletResponse
getBufferSize
in class javax.servlet.ServletResponseWrapper
public String getCharacterEncoding()
getCharacterEncoding
in interface javax.servlet.ServletResponse
getCharacterEncoding
in class javax.servlet.ServletResponseWrapper
public String getContentType()
getContentType
in interface javax.servlet.ServletResponse
getContentType
in class javax.servlet.ServletResponseWrapper
public Locale getLocale()
getLocale
in interface javax.servlet.ServletResponse
getLocale
in class javax.servlet.ServletResponseWrapper
public javax.servlet.ServletOutputStream getOutputStream() throws IOException
getOutputStream
in interface javax.servlet.ServletResponse
getOutputStream
in class javax.servlet.ServletResponseWrapper
IOException
public PrintWriter getWriter() throws IOException
getWriter
in interface javax.servlet.ServletResponse
getWriter
in class javax.servlet.ServletResponseWrapper
IOException
public boolean isCommitted()
isCommitted
in interface javax.servlet.ServletResponse
isCommitted
in class javax.servlet.ServletResponseWrapper
public void reset()
reset
in interface javax.servlet.ServletResponse
reset
in class javax.servlet.ServletResponseWrapper
public void resetBuffer()
resetBuffer
in interface javax.servlet.ServletResponse
resetBuffer
in class javax.servlet.ServletResponseWrapper
public void sendError(int errorCode, String errorMessage) throws IOException
HstResponse
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
sendError
in interface HstResponse
sendError
in class javax.servlet.http.HttpServletResponseWrapper
errorCode
- the error status codeerrorMessage
- the descriptive message
IOException
- If the response was committedpublic void sendError(int errorCode) throws IOException
HstResponse
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
sendError
in interface HstResponse
sendError
in class javax.servlet.http.HttpServletResponseWrapper
errorCode
- the error status code
IOException
- If the response was committedpublic void sendRedirect(String redirectLocation) throws IOException
HstResponse
When a component runs on a normal servlet environment,
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.
Meanwhile, when a component runs on a portal/portlet environment,
in HstComponent.doAction(HstRequest, HstResponse)
,
the invocation on this method is effective.
However, in other methods including HstComponent.doBeforeRender(HstRequest, HstResponse)
,
the invocation on this method will be just ignored.
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
sendRedirect
in interface HstResponse
sendRedirect
in class javax.servlet.http.HttpServletResponseWrapper
redirectLocation
- the redirect location URL
IOException
javax.servlet.http,HttpServletResponse#sendRedirect(String)}
public void setBufferSize(int size)
setBufferSize
in interface javax.servlet.ServletResponse
setBufferSize
in class javax.servlet.ServletResponseWrapper
public void setCharacterEncoding(String charset)
setCharacterEncoding
in interface javax.servlet.ServletResponse
setCharacterEncoding
in class javax.servlet.ServletResponseWrapper
public void setContentLength(int len)
setContentLength
in interface javax.servlet.ServletResponse
setContentLength
in class javax.servlet.ServletResponseWrapper
public void setContentType(String type)
setContentType
in interface javax.servlet.ServletResponse
setContentType
in class javax.servlet.ServletResponseWrapper
public void setDateHeader(String name, long date)
setDateHeader
in interface javax.servlet.http.HttpServletResponse
setDateHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setHeader(String name, String value)
setHeader
in interface javax.servlet.http.HttpServletResponse
setHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setIntHeader(String name, int value)
setIntHeader
in interface javax.servlet.http.HttpServletResponse
setIntHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setLocale(Locale locale)
setLocale
in interface javax.servlet.ServletResponse
setLocale
in class javax.servlet.ServletResponseWrapper
public void setStatus(int statusCode, String message)
setStatus
in interface javax.servlet.http.HttpServletResponse
setStatus
in class javax.servlet.http.HttpServletResponseWrapper
public void setStatus(int statusCode)
HstResponse
If there are multiple HST components to invoke this method, then the last invocation will be applied.
setStatus
in interface javax.servlet.http.HttpServletResponse
setStatus
in interface HstResponse
setStatus
in class javax.servlet.http.HttpServletResponseWrapper
public String encodeRedirectUrl(String url)
encodeRedirectUrl
in interface javax.servlet.http.HttpServletResponse
encodeRedirectUrl
in class javax.servlet.http.HttpServletResponseWrapper
public String encodeRedirectURL(String url)
encodeRedirectURL
in interface javax.servlet.http.HttpServletResponse
encodeRedirectURL
in class javax.servlet.http.HttpServletResponseWrapper
public String encodeUrl(String url)
encodeUrl
in interface javax.servlet.http.HttpServletResponse
encodeUrl
in class javax.servlet.http.HttpServletResponseWrapper
public String encodeURL(String url)
encodeURL
in interface javax.servlet.http.HttpServletResponse
encodeURL
in class javax.servlet.http.HttpServletResponseWrapper
public Element createElement(String tagName)
HstResponse
#addProperty(String, Element)
method.
createElement
in interface HstResponse
tagName
- the tag name of the element
public Comment createComment(String comment)
HstResponse
createComment
in interface HstResponse
comment
- the comment text
public void addHeadElement(Element element, String keyHint)
HstResponse
addHeadElement
in interface HstResponse
public List<Element> getHeadElements()
HstResponse
HstResponse.addHeadElement(Element, String)
,
then the portal will write all the merged head tag elements finally.
getHeadElements
in interface HstResponse
public boolean containsHeadElement(String keyHint)
HstResponse
containsHeadElement
in interface HstResponse
public void addPreamble(Comment comment)
HstResponse
addPreamble
in interface HstResponse
comment
- the comment nodepublic void setWrapperElement(Element element)
HstResponse
setWrapperElement
in interface HstResponse
public Element getWrapperElement()
HstResponse
getWrapperElement
in interface HstResponse
public void setRenderParameter(String key, String value)
HstResponse
setRenderParameter
in interface HstResponse
key
- key of the render parametervalue
- value of the render parameterpublic void setRenderParameter(String key, String[] values)
HstResponse
setRenderParameter
in interface HstResponse
key
- key of the render parametervalues
- values of the render parameterspublic void setRenderParameters(Map<String,String[]> parameters)
HstResponse
setRenderParameters
in interface HstResponse
public Map<String,String[]> getRenderParameters()
public void setRenderPath(String renderPath)
HstResponse
HstComponent.doBeforeRender(HstRequest, HstResponse)
method.
setRenderPath
in interface HstResponse
public String getRenderPath()
public void setServeResourcePath(String serveResourcePath)
HstResponse
HstComponent.doBeforeServeResource(HstRequest, HstResponse)
method.
setServeResourcePath
in interface HstResponse
public void flushChildContent(String name) throws IOException
HstResponse
Note: the child content can be flushed only once. If it is already flushed, then the next invocations will not make any effect.
flushChildContent
in interface HstResponse
name
- the name of the child window
IOException
public List<String> getChildContentNames()
HstResponse
getChildContentNames
in interface HstResponse
public void forward(String pathInfo) throws IOException
HstResponse
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.
forward
in interface HstResponse
pathInfo
- the path info to forward. It should start with a "/" and is relative to the root of your hst sitemap
IOException
- If the response was committedpublic boolean isRendererSkipped()
HstResponseImpl
never gets its renderer skipped
isRendererSkipped
in interface HstResponse
true
when for this HstResponse
the renderer won't be invoked
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |