EAF 7.6 Implementation

com.lutris.appserver.server.httpPresentation.servlet
Class ServletHttpPresentationResponse

java.lang.Object
  extended by com.lutris.appserver.server.httpPresentation.servlet.ServletHttpPresentationResponse
All Implemented Interfaces:
com.lutris.appserver.server.httpPresentation.HttpPresentationResponse

public class ServletHttpPresentationResponse
extends java.lang.Object
implements com.lutris.appserver.server.httpPresentation.HttpPresentationResponse

Object passed to presentation objects that is used to generate HTTP responses.


Field Summary
 
Fields inherited from interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CREATED, SC_FORBIDDEN, SC_INTERNAL_SERVER_ERROR, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_NO_CONTENT, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_SERVICE_UNAVAILABLE, SC_UNAUTHORIZED
 
Constructor Summary
protected ServletHttpPresentationResponse(javax.servlet.http.HttpServletResponse response, java.io.PrintWriter domStatsLogWriter)
          Construct an object associated with a servlet response.
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds the specified cookie to the response.
 boolean containsHeader(java.lang.String name)
          Returns true if the response message header has a field with the specified name.
 org.enhydra.xml.io.OutputOptions createOutputOptions(org.enhydra.xml.xmlc.XMLObject document)
          Create an OutputOptions object for a document.
 java.lang.String encodeRedirectUrl(java.lang.String url)
          Encodes a url with session id for sendRedirect for use with cookieless browsers.
 java.lang.String encodeUrl(java.lang.String url)
          Encodes a url with session id for use with cookieless browsers.
 void flush()
          Called at the end of processing a response to force any cached headers to be written and buffers flushed.
 int getContentLength()
          Returns the size of the request entity data, or -1 if not available.
 java.lang.String getContentType()
          Returns the Internet Media Type of the response, or null if not known This is necessary to support the DebugResponse interface.
 javax.servlet.http.Cookie[] getCookies()
          Returns an array of cookies to be set by this response, or a 0 length array if the information is not available.
 java.lang.String getEncoding()
          Get the output character encoding.
 java.lang.String getHeader(java.lang.String name)
          Returns the values of the specified header for the response as an array of strings, or a 0 length array if the named header does not exist.
 java.util.Enumeration getHeaderNames()
          Returns an array of strings representing the header names for this response.
 javax.servlet.http.HttpServletResponse getHttpServletResponse()
          Returns the original HttpServletResponse.
 com.lutris.appserver.server.httpPresentation.HttpPresentationOutputStream getOutputStream()
          Returns an output stream for writing response data.
 ResponsePostProcessingManager getPostProcessingManager()
          Returns the response post processing manager.
 java.lang.String getResponseData()
          Returns null.
 int getStatusCode()
          Returns the status code for the response, or -1 if not available.
 java.lang.String getStatusMessage()
          Returns the status message for the response, or null if not available.
 int getTotalBytes()
          Returns the total number of bytes that make up this response.
 boolean isSessionIdCookieRequired()
          Indicates whether client response requires a sessionId cookie
 boolean isSessionIdEncodeUrlRequired()
          Indicates whether client response requires url encoding for sessionId
 void sendError(int sc)
          Sends an error response to the client using the specified status code and a default message.
 void sendError(int sc, java.lang.String msg)
          Sends an error response to the client using the specified status code and descriptive message.
 void setContentLength(int len)
          Sets the content length for this response.
 void setContentType(java.lang.String type)
          Sets the content type for this response.
 void setDateHeader(java.lang.String name, long date)
          Adds a field to the response header with a given name and date-valued field.
 void setEncoding(java.lang.String enc)
          Set the output character encoding.
 void setHeader(java.lang.String name, java.lang.String value)
          Adds a field to the response header with a given name and value.
 void setIntHeader(java.lang.String name, int value)
          Adds a field to the response header with a given name and integer value.
 void setPostProcessingManager(ResponsePostProcessingManager processingManager)
          Sets the response post processing manager.
 void setSessionIdCookieRequired(boolean sessionIdCookie)
           
 void setSessionIdEncodeUrlRequired(boolean sessionIdUrl)
           
 void setSessionKey(java.lang.String sessionKey)
          Sets the current session key for this response
 void setSessionManager(com.lutris.appserver.server.session.SessionManager sessionManager)
          Sets the session manager.
 void setStatus(int sc)
          Sets the status code and a default message for this response.
 void setStatus(int sc, java.lang.String sm)
          Sets the status code and message for this response.
 void writeDOM(org.w3c.dom.Node document)
          Output an an XMLC document object (DOM).
 void writeDOM(org.enhydra.xml.io.OutputOptions outputOptions, org.w3c.dom.Node document)
          Output an an XMLC document object (DOM).
 void writeHTML(org.w3c.dom.html.HTMLDocument doc)
          Deprecated. use writeDOM
 void writeHTML(java.lang.String html)
          Utility method to output an HTML page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletHttpPresentationResponse

protected ServletHttpPresentationResponse(javax.servlet.http.HttpServletResponse response,
                                          java.io.PrintWriter domStatsLogWriter)
Construct an object associated with a servlet response.

Parameters:
response - Servlet response object that this object will front-end.
Method Detail

getHttpServletResponse

public javax.servlet.http.HttpServletResponse getHttpServletResponse()
Returns the original HttpServletResponse.

Specified by:
getHttpServletResponse in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse

setContentLength

public void setContentLength(int len)
                      throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Sets the content length for this response.

Specified by:
setContentLength in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
len - the content length
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

setContentType

public void setContentType(java.lang.String type)
                    throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Sets the content type for this response.

Specified by:
setContentType in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
type - the content's MIME type
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

getOutputStream

public com.lutris.appserver.server.httpPresentation.HttpPresentationOutputStream getOutputStream()
                                                                                          throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Returns an output stream for writing response data.

Specified by:
getOutputStream in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
               throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Adds the specified cookie to the response. It can be called multiple times to set more than one cookie.

Specified by:
addCookie in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
cookie - - The Cookie to return to the client.
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

containsHeader

public boolean containsHeader(java.lang.String name)
                       throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Returns true if the response message header has a field with the specified name.

Specified by:
containsHeader in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
name - the header field name
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

setStatus

public void setStatus(int sc,
                      java.lang.String sm)
               throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Sets the status code and message for this response.

Specified by:
setStatus in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
sc - the status code
sm - the status message
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

setStatus

public void setStatus(int sc)
               throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Sets the status code and a default message for this response.

Specified by:
setStatus in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
sc - the status code
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
               throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Adds a field to the response header with a given name and value. If the field had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setHeader in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
name - the header field name
value - the header field value
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
                  throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Adds a field to the response header with a given name and integer value. If the field had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setIntHeader in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
name - the header field name
value - the header field integer value
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

setDateHeader

public void setDateHeader(java.lang.String name,
                          long date)
                   throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Adds a field to the response header with a given name and date-valued field. The date is specified in terms of milliseconds since the epoch. If the date field had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Specified by:
setDateHeader in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
name - the header field name
value - the header field date value
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

sendError

public void sendError(int sc,
                      java.lang.String msg)
               throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Sends an error response to the client using the specified status code and descriptive message.

Specified by:
sendError in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
sc - the status code
msg - the detail message
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

sendError

public void sendError(int sc)
               throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Sends an error response to the client using the specified status code and a default message.

Specified by:
sendError in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
sc - the status code
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

flush

public void flush()
           throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Called at the end of processing a response to force any cached headers to be written and buffers flushed.

Specified by:
flush in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

encodeUrl

public java.lang.String encodeUrl(java.lang.String url)
Encodes a url with session id for use with cookieless browsers.

Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String url)
Encodes a url with session id for sendRedirect for use with cookieless browsers.

Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.
See Also:
#sendRedirect, encodeUrl(java.lang.String)

getContentLength

public int getContentLength()
Returns the size of the request entity data, or -1 if not available. This is necessary to support the DebugResponse interface.

Returns:
the content length.
See Also:
com.lutris.http.debug.DebugResponse

getContentType

public java.lang.String getContentType()
Returns the Internet Media Type of the response, or null if not known This is necessary to support the DebugResponse interface.

Returns:
the content type.
See Also:
com.lutris.http.debug.DebugResponse

getStatusCode

public int getStatusCode()
Returns the status code for the response, or -1 if not available. This is necessary to support the DebugResponse interface.

Returns:
the status code.
See Also:
com.lutris.http.debug.DebugResponse

getStatusMessage

public java.lang.String getStatusMessage()
Returns the status message for the response, or null if not available. This is necessary to support the DebugResponse interface.

Returns:
the status message.
See Also:
com.lutris.http.debug.DebugResponse

getCookies

public javax.servlet.http.Cookie[] getCookies()
Returns an array of cookies to be set by this response, or a 0 length array if the information is not available. This is necessary to support the DebugResponse interface.

Returns:
The array of cookies found in this response.
See Also:
com.lutris.http.debug.DebugResponse

getHeader

public java.lang.String getHeader(java.lang.String name)
Returns the values of the specified header for the response as an array of strings, or a 0 length array if the named header does not exist. This is necessary to support the DebugResponse interface.

Parameters:
name - the case-insensitive header field name
Returns:
the value of the supplied header.
See Also:
com.lutris.http.debug.DebugResponse

getHeaderNames

public java.util.Enumeration getHeaderNames()
Returns an array of strings representing the header names for this response. This does not have return cookies - use getCookies().

Returns:
name the case-insensitive header field name
See Also:
com.lutris.http.debug.DebugResponse

getTotalBytes

public int getTotalBytes()
Returns the total number of bytes that make up this response. This is not supported for Jolt Presentations and is necessary to support the DebugResponse interface.

Returns:
the total number of bytes in the response.
See Also:
com.lutris.http.debug.DebugResponse

getResponseData

public java.lang.String getResponseData()
Returns null. Normally this function returns the data written to the output stream associated with this request.


setEncoding

public void setEncoding(java.lang.String enc)
Set the output character encoding.

Specified by:
setEncoding in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
enc - character encoding

getEncoding

public java.lang.String getEncoding()
Get the output character encoding.

Specified by:
getEncoding in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse

setSessionKey

public void setSessionKey(java.lang.String sessionKey)
Sets the current session key for this response

Specified by:
setSessionKey in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
sessionKey - The current sessionKey

setSessionManager

public void setSessionManager(com.lutris.appserver.server.session.SessionManager sessionManager)
Sets the session manager.

Specified by:
setSessionManager in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse

setPostProcessingManager

public void setPostProcessingManager(ResponsePostProcessingManager processingManager)
Sets the response post processing manager.

Specified by:
setPostProcessingManager in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
processingManager -

getPostProcessingManager

public ResponsePostProcessingManager getPostProcessingManager()
Returns the response post processing manager.

Specified by:
getPostProcessingManager in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse

isSessionIdCookieRequired

public boolean isSessionIdCookieRequired()
                                  throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Indicates whether client response requires a sessionId cookie

Specified by:
isSessionIdCookieRequired in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Returns:
true if client response requires a sessionId cookie false otherwise
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

setSessionIdCookieRequired

public void setSessionIdCookieRequired(boolean sessionIdCookie)
                                throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Specified by:
setSessionIdCookieRequired in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

isSessionIdEncodeUrlRequired

public boolean isSessionIdEncodeUrlRequired()
                                     throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Indicates whether client response requires url encoding for sessionId

Specified by:
isSessionIdEncodeUrlRequired in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Returns:
true if client response requires url encoding for sessionId; false otherwise
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

setSessionIdEncodeUrlRequired

public void setSessionIdEncodeUrlRequired(boolean sessionIdUrl)
                                   throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Specified by:
setSessionIdEncodeUrlRequired in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

createOutputOptions

public org.enhydra.xml.io.OutputOptions createOutputOptions(org.enhydra.xml.xmlc.XMLObject document)
                                                     throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Create an OutputOptions object for a document. Options are default for the specified document. The object maybe then modified as needed to override the default values.

The following attributes are set in the object:

Specified by:
createOutputOptions in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

writeDOM

public void writeDOM(org.enhydra.xml.io.OutputOptions outputOptions,
                     org.w3c.dom.Node document)
              throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Output an an XMLC document object (DOM). The document is formatted according to it's type. The MIME type of the response is automatically set.

Specified by:
writeDOM in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
outputFormat - Object use to specify options controlling formatting of the document.
doc - The DOM object to be returned as response.
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

writeDOM

public void writeDOM(org.w3c.dom.Node document)
              throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Output an an XMLC document object (DOM). The document is formatted according to it's type. The MIME type of the response is automatically set.

Specified by:
writeDOM in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
doc - The DOM object to be returned as response.
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

writeHTML

public void writeHTML(java.lang.String html)
               throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Utility method to output an HTML page. The appropriate headers are set for MIME type and to disable caching of the HTML by the broswer.

Specified by:
writeHTML in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

writeHTML

public void writeHTML(org.w3c.dom.html.HTMLDocument doc)
               throws com.lutris.appserver.server.httpPresentation.HttpPresentationException
Deprecated. use writeDOM

Utility method to output an HTML page from a DOM object. The appropriate headers are set for MIME type and to disable caching of the HTML by the broswer.

Specified by:
writeHTML in interface com.lutris.appserver.server.httpPresentation.HttpPresentationResponse
Parameters:
doc - The DOM object to be returned as response
Throws:
com.lutris.appserver.server.httpPresentation.HttpPresentationException

EAF 7.6 Implementation