electric.servlet
Class OutboundHTTPResponse

java.lang.Object
  extended byelectric.servlet.OutboundHTTPResponse
All Implemented Interfaces:
javax.servlet.http.HttpServletResponse, IHTTPConstants, javax.servlet.ServletResponse

public class OutboundHTTPResponse
extends java.lang.Object
implements javax.servlet.http.HttpServletResponse, IHTTPConstants

HTTPResponse is an implementation of the standard HttpServletResponse interface.

Author:
webMethods

Field Summary
 
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_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
 
Fields inherited from interface electric.util.http.IHTTPConstants
ACCEPT_LANGUAGE, ACCEPT_RANGES, APPLICATION_BINARY, APPLICATION_OCTET_STREAM, ASCII, AUTHORIZATION, BASIC, BOUNDARY, CHARSET_EQUALS, CHUNKED, CLOSE, COLON_SLASH_SLASH, CONNECT, CONNECTION, CONTENT_ID, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_TYPE, CONTINUATION_STATUS, CONTINUE_EXPECTATION, COOKIE, COOKIE_LISTENER, DATE, DEFAULT_CONTENT_TYPE, DEFAULT_HTTP_CHARSET, DEFAULT_HTTPS_PORT, DEFAULT_MIME_TYPE, DEFAULT_PROXY_PORT, DIGEST, EOL, EXPECT, EXPECT_HEADER, FORM_URLENCODED, GET, GLUE_SESSION, HEAD, HOST, HTTP_1_0, HTTP_1_1, HTTP_PROTOCOL, HTTPS_PROTOCOL, IF_MODIFIED_SINCE, KEEP_ALIVE, LAST_MODIFIED, LOCATION, MD5_HASH, MIME_BOUNDARY, MIME_VERSION, MULTIPART_CONTENT_TYPE, OK, POST, PROXY_AUTHORIZATION, RANGE, SC_CONTINUE, SC_MOVED, SC_MOVED_PERMANENTLY, SC_OK, SC_PROXY_AUTHENTICATION_REQUIRED, SC_UNAUTHORIZED, SEPARATOR, SERVER, SERVER_PREFIX, SERVER_TYPE, SET_COOKIE_0, SET_COOKIE_1, SLASH, START, TEXT_HTML, TEXT_PLAIN, TEXT_XML, TEXT_XML_UTF_8, TRANSFER_ENCODING, USER_AGENT, WWW_AUTHENTICATE
 
Constructor Summary
OutboundHTTPResponse()
           
OutboundHTTPResponse(InboundHTTPRequest request)
           
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Add a cookie.
 void addDateHeader(java.lang.String name, long date)
          Add a header with the specified name and date.
 void addHeader(java.lang.String name, java.lang.String value)
          Add a header with the specified name and value.
 void addIntHeader(java.lang.String name, int value)
          Add a header with the specified name and value.
 void clearHeaders()
          Clear all of my headers.
 boolean containsHeader(java.lang.String name)
          Return true if there is at least one header with the specified name.
 java.lang.String encodeRedirectUrl(java.lang.String url)
           
 java.lang.String encodeRedirectURL(java.lang.String url)
           
 java.lang.String encodeUrl(java.lang.String url)
           
 java.lang.String encodeURL(java.lang.String url)
           
 void flushBuffer()
           
 void flushHeaders()
           
 int getBufferSize()
           
 IChannel getChannel()
           
 java.lang.String getCharacterEncoding()
          Return my character encoding.
 int getContentLength()
          Return my content length, or -1 if none is defined.
 java.lang.String getHeader(java.lang.String name)
          Return the header with the specified name.
 int getIntHeader(java.lang.String name)
          Return the value of the header with the specified name, or -1 if none is defined.
 java.util.Locale getLocale()
           
 java.lang.String getMessage()
          For internal use by HTTPCcontext.configureErrorMessage.
 javax.servlet.ServletOutputStream getOutputStream()
           
 int getStatus()
          Return the status.
 java.io.PrintWriter getWriter()
           
 void internalResetBuffer()
          for internal use only.
 boolean isCommitted()
           
 void reset()
           
 void resetBuffer()
           
 void resetStreams()
          If there is an exception, we want to write an error message instead of the servlet output.
 void sendError(int status)
           
 void sendError(int status, java.lang.String message)
           
 void sendRedirect(java.lang.String location)
           
 void setBufferSize(int bufferSize)
           
 void setChannel(IChannel channel)
           
 void setContentLength(int length)
          Set my content length.
 void setContentType(java.lang.String contentType)
          Set the HTTP Content-Type header.
 void setDateHeader(java.lang.String name, long date)
          Set a header with the specified name and date.
 void setHeader(java.lang.String name, java.lang.String value)
          Set a header with the specified name and value.
 void setIntHeader(java.lang.String name, int value)
          Set a header with the specified name and value.
 void setKeepAlive(InboundHTTPRequest request)
          Conditionally set the Connection header.
 void setLocale(java.util.Locale locale)
          Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.
 void setStatus(int status)
          Set the status.
 void setStatus(int status, java.lang.String message)
           
 void setVersion(java.lang.String version)
          Set my version.
 java.lang.String toString()
           
 void writeHeaders()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OutboundHTTPResponse

public OutboundHTTPResponse()

OutboundHTTPResponse

public OutboundHTTPResponse(InboundHTTPRequest request)
Parameters:
request -
Method Detail

toString

public java.lang.String toString()

getChannel

public IChannel getChannel()

setChannel

public void setChannel(IChannel channel)
Parameters:
channel -

setVersion

public void setVersion(java.lang.String version)
Set my version.

Parameters:
version - The new value.

getContentLength

public int getContentLength()
Return my content length, or -1 if none is defined.


setContentLength

public void setContentLength(int length)
Set my content length.

Specified by:
setContentLength in interface javax.servlet.ServletResponse
Parameters:
length - The new value.

setContentType

public void setContentType(java.lang.String contentType)
Set the HTTP Content-Type header. The header value may contain a "charset" parameter which will implicitly reset the response locale.

Specified by:
setContentType in interface javax.servlet.ServletResponse
Parameters:
contentType - an http Content-Type header value

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Return my character encoding.

Specified by:
getCharacterEncoding in interface javax.servlet.ServletResponse

flushHeaders

public void flushHeaders()
                  throws java.io.IOException
Throws:
java.io.IOException

writeHeaders

public void writeHeaders()
                  throws java.io.IOException
Throws:
java.io.IOException

clearHeaders

public void clearHeaders()
Clear all of my headers.


getHeader

public java.lang.String getHeader(java.lang.String name)
Return the header with the specified name. If there is more than one header with this name, return the first one.

Parameters:
name - The name.

containsHeader

public boolean containsHeader(java.lang.String name)
Return true if there is at least one header with the specified name.

Specified by:
containsHeader in interface javax.servlet.http.HttpServletResponse
Parameters:
name - The name.

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Set a header with the specified name and value. If at least one header already exists with the name, replace the value of the first matching header, otherwise add a new header.

Specified by:
setHeader in interface javax.servlet.http.HttpServletResponse
Parameters:
name - The name.
value - The value.

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Add a header with the specified name and value.

Specified by:
addHeader in interface javax.servlet.http.HttpServletResponse
Parameters:
name - The name.
value - The value.

getIntHeader

public int getIntHeader(java.lang.String name)
Return the value of the header with the specified name, or -1 if none is defined.

Parameters:
name - The name.

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
Set a header with the specified name and value. If at least one header already exists with the name, replace the value of the first matching header, otherwise add a new header.

Specified by:
setIntHeader in interface javax.servlet.http.HttpServletResponse
Parameters:
name - The name.
value - The value.

addIntHeader

public void addIntHeader(java.lang.String name,
                         int value)
Add a header with the specified name and value.

Specified by:
addIntHeader in interface javax.servlet.http.HttpServletResponse
Parameters:
name - The name.
value - The value.

setDateHeader

public void setDateHeader(java.lang.String name,
                          long date)
Set a header with the specified name and date. If at least one header already exists with the name, replace the date of the first matching header, otherwise add a new header.

Specified by:
setDateHeader in interface javax.servlet.http.HttpServletResponse
Parameters:
name - The name.
date - The date.

addDateHeader

public void addDateHeader(java.lang.String name,
                          long date)
Add a header with the specified name and date.

Specified by:
addDateHeader in interface javax.servlet.http.HttpServletResponse
Parameters:
name - The name.
date - The date.

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. This method should be called before a call to getWriter().

Specified by:
setLocale in interface javax.servlet.ServletResponse
Parameters:
locale - the locale of the response

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface javax.servlet.ServletResponse

reset

public void reset()
           throws java.lang.IllegalStateException
Specified by:
reset in interface javax.servlet.ServletResponse
Throws:
java.lang.IllegalStateException

resetBuffer

public void resetBuffer()
                 throws java.lang.IllegalStateException
Specified by:
resetBuffer in interface javax.servlet.ServletResponse
Throws:
java.lang.IllegalStateException

internalResetBuffer

public void internalResetBuffer()
for internal use only.


flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Specified by:
flushBuffer in interface javax.servlet.ServletResponse
Throws:
java.io.IOException

isCommitted

public boolean isCommitted()
Specified by:
isCommitted in interface javax.servlet.ServletResponse

getBufferSize

public int getBufferSize()
Specified by:
getBufferSize in interface javax.servlet.ServletResponse

setBufferSize

public void setBufferSize(int bufferSize)
Specified by:
setBufferSize in interface javax.servlet.ServletResponse
Parameters:
bufferSize -

getMessage

public java.lang.String getMessage()
For internal use by HTTPCcontext.configureErrorMessage.

Returns:
the currently set http response message

getStatus

public int getStatus()
Return the status.


setStatus

public void setStatus(int status)
Set the status.

Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse
Parameters:
status - The new value.

setStatus

public void setStatus(int status,
                      java.lang.String message)
Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse
Parameters:
status -
message -

sendError

public void sendError(int status)
               throws java.io.IOException
Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
Parameters:
status -
Throws:
java.io.IOException

sendError

public void sendError(int status,
                      java.lang.String message)
               throws java.io.IOException
Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
Parameters:
status -
message -
Throws:
java.io.IOException

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Add a cookie.

Specified by:
addCookie in interface javax.servlet.http.HttpServletResponse
Parameters:
cookie - The cookie.

setKeepAlive

public void setKeepAlive(InboundHTTPRequest request)
Conditionally set the Connection header. HTTP/1.0 requests with Keep-Alive expect a Keep-Alive token in the response. Note that it depends on the _request_ version, not the (possibly upgraded) version in this response.

Parameters:
request -

encodeRedirectURL

public java.lang.String encodeRedirectURL(java.lang.String url)
Specified by:
encodeRedirectURL in interface javax.servlet.http.HttpServletResponse
Parameters:
url -

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String url)
Specified by:
encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse
Parameters:
url -

encodeURL

public java.lang.String encodeURL(java.lang.String url)
Specified by:
encodeURL in interface javax.servlet.http.HttpServletResponse
Parameters:
url -

encodeUrl

public java.lang.String encodeUrl(java.lang.String url)
Specified by:
encodeUrl in interface javax.servlet.http.HttpServletResponse
Parameters:
url -

sendRedirect

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException
Specified by:
sendRedirect in interface javax.servlet.http.HttpServletResponse
Parameters:
location -
Throws:
java.io.IOException

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws java.io.IOException
Specified by:
getOutputStream in interface javax.servlet.ServletResponse
Throws:
java.io.IOException

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Specified by:
getWriter in interface javax.servlet.ServletResponse
Throws:
java.io.IOException

resetStreams

public void resetStreams()
                  throws java.io.IOException
If there is an exception, we want to write an error message instead of the servlet output. Since we can't tell what's already been written, just throw away the existing streams. This method should only be called from internal GLUE code.

Throws:
java.io.IOException


copyright© 2001-2004 by webMethods All Rights Reserved.