org.enhydra.servlet.connectionMethods.EnhydraDirector
Class EnhydraDirectorConnection

java.lang.Object
  extended byorg.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol
      extended byorg.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorConnection

public class EnhydraDirectorConnection
extends EnhydraDirectorProtocol


Field Summary
static java.lang.String DEFAULT_ENCODING
           
static java.lang.String FORM_POST_MIME_TYPE
          Standard Mime type for POST-ed forms.
 
Fields inherited from class org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol
active, clientMajor, clientMinor, MAJOR_VERSION, MAX_AUTHDATA_LENGTH, MAX_FUNCDATA_LENGTH, MAX_SMALL_PACKET_LENGTH, MINOR_VERSION, PKT_HEADER_SIZE, PKT_OPENFLAGS_HEADERCB, PKT_OPENFLAGS_OPENCB, PKT_SUBTYPE_AUTH_CLI, PKT_SUBTYPE_AUTH_FAIL, PKT_SUBTYPE_AUTH_OK, PKT_SUBTYPE_AUTH_SVR, PKT_SUBTYPE_CTRL_CLI_ACTIVATE, PKT_SUBTYPE_CTRL_CLI_CLOSE, PKT_SUBTYPE_CTRL_CLI_DEACTIVATE, PKT_SUBTYPE_CTRL_SVR_REFRESH, PKT_SUBTYPE_FUNC_CALL, PKT_SUBTYPE_FUNC_END, PKT_SUBTYPE_FUNC_FAIL, PKT_SUBTYPE_FUNC_OK, PKT_SUBTYPE_FUNC_ONEWAY, PKT_SUBTYPE_HEADER_COOKIE, PKT_SUBTYPE_HEADER_HEADER, PKT_SUBTYPE_HEADER_HTTP, PKT_SUBTYPE_HEADER_LAST, PKT_SUBTYPE_PROTO_CLOSE, PKT_SUBTYPE_PROTO_FATAL, PKT_SUBTYPE_PROTO_VERSION, PKT_SUBTYPE_REQ_DATA, PKT_SUBTYPE_REQ_LASTDATA, PKT_SUBTYPE_RESP_DATA, PKT_SUBTYPE_RESP_END, PKT_SUBTYPE_RESP_ERROR, PKT_SUBTYPE_RESP_LOGS, PKT_SUBTYPE_RESP_WARNING, PKT_TYPE_AUTH, PKT_TYPE_CTRL_CLI, PKT_TYPE_CTRL_SVR, PKT_TYPE_FUNC, PKT_TYPE_HEADER, PKT_TYPE_PROTO, PKT_TYPE_REQ, PKT_TYPE_RESP, state, STATE_CHECK_AUTH, STATE_CLOSED, STATE_HAVE_HEADERS, STATE_NEWCONNECT, STATE_OPEN, STATE_OPENING, STATE_PROCESSING_ENTITY_FUNC, STATE_PROCESSING_FUNC, STATE_PROCESSING_HEADER, STATE_PROCESSING_REQUEST, STATE_RECEIVING_ENTITY, STATE_RECEIVING_HEADERS, STATE_WAIT_AUTH, STATE_WAIT_ENTITY_CALLBACK, STATE_WAIT_HEADER_CALLBACK, STATE_WAIT_OPEN_CALLBACK, STATE_WAIT_VERSION
 
Constructor Summary
EnhydraDirectorConnection()
           
 
Method Summary
 void activate()
          Override the activate() method to allow per-connection variables to be reset for each new connection.
 void addCookie(javax.servlet.http.Cookie cookie)
          Add a cookie to the list of cookies to send to the browser.
 void addDateHeader(java.lang.String name, long date)
          Adds a response header with the given name and date value.
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a response header with the given name and integer value.
 void addIntHeader(java.lang.String name, int value)
          Adds a response header with the given name and integer value.
protected  boolean authRequired()
          Implementation class must provide this method.
 void closeInput()
          Discards any further incoming request entity data and marks the input stream as "closed".
 void closeOutput()
          Method to close output stream.
 boolean containsHeader(java.lang.String name)
          Returns true if the current response contains the named header.
 void doWrite(byte[] buffer, int pos, int count)
          Write a chunk of bytes.
 java.lang.String encodeRedirectUrl(java.lang.String url)
          Encodes the specified URL for use in the sendRedirect method.
 java.lang.String encodeRedirectURL(java.lang.String url)
           
 java.lang.String encodeUrl(java.lang.String url)
          Encodes the specified URL by including the session ID in it, or if encoding is not needed, returns the URL unchanged.
 java.lang.String encodeURL(java.lang.String url)
          mora servlet response Sets the locale of the response.
 void flushBuffer()
          Forces any content in the buffer to be written to the client.
 java.lang.String formatResponseCookie(javax.servlet.http.Cookie cookie)
           
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of an attribute of the request.
 java.util.Enumeration getAttributeNames()
           
protected  byte[] getAuthData()
          Abstract method to get authentication secret data.
 java.lang.String getAuthType()
          Gets the authentication scheme of this request.
 int getBufferSize()
          Returns the actual buffer size used for the response.
 java.lang.String getCharacterEncoding()
          Returns the charset used for the body.
 int getContentLength()
          Get the size of the request data.
 java.lang.String getContentType()
          Get the content type of the request.
 javax.servlet.http.Cookie[] getCookies()
          Gets the array of cookies found in this request.
 long getDateHeader(java.lang.String name)
          Gets the value of the requested date header field of this request.
 boolean getEnableLookups()
           
protected  EnhydraDirectorFunction getFunction(int type)
          Internal dispatch table for server side function handlers.
 java.lang.String getHeader(java.lang.String name)
          Gets the value of the requested header field of this request.
 java.util.Enumeration getHeaderNames()
          Gets the header names for this request.
 java.util.Enumeration getHeaders(java.lang.String name)
          Returns all the values of the specified requst header as an Enumeration of String objects.
 java.lang.String getHost()
          Get the host name
 java.net.InetAddress getInetAddress()
           
 javax.servlet.ServletInputStream getInputStream()
          Get an input stream for reading binary data in the request body.
 int getIntHeader(java.lang.String name)
          Gets the value of the specified integer header field of this request.
 java.lang.String getIPPortToken()
           
 java.lang.String getLocalAddr()
          Returns the Internet Protocol (IP) address of the interface on which the request was received.
 java.lang.String getLocalName()
          Returns the host name of the Internet Protocol (IP) interface on which the request was received.
 int getLocalPort()
          Returns the Internet Protocol (IP) port number of the interface on which the request was received.
 java.lang.String getMessage()
           
 java.lang.String getMethod()
          Gets the HTTP method (for example, GET, POST, PUT) with which this request was made.
 javax.servlet.ServletOutputStream getOutputStream()
          Returns the byte output stream object for this response.
 java.lang.String getParameter(java.lang.String name)
          Get a string containing the lone value of the specified parameter.
 java.util.Enumeration getParameterNames()
          Get the parameter names for this request.
 java.lang.String[] getParameterValues(java.lang.String name)
          Get the values of the specified parameter for the request.
 java.lang.String getProtocol()
          Get the protocol and version of the request.
 java.lang.String getQueryString()
          Gets any query string that is part of the HTTP request URI.
 java.io.BufferedReader getReader()
          Returns a buffered reader for reading text in the request body.
 java.lang.String getRemoteAddr()
          Get the IP address of the agent that sent the request.
 java.lang.String getRemoteHost()
          Get the fully qualified host name of the agent that sent the request.
 int getRemotePort()
          Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
 java.lang.String getRemoteUser()
          Gets the name of the user making this request.
 java.lang.String getRequestURI()
          Get the part of this request's URI that is to the left of any query string.
 java.lang.StringBuffer getRequestURL()
          Reconstructs the URL the client used to make the request.
 int getResponseContentLength()
          Return the Content Length associated with this Response.
 java.lang.String getResponseContentType()
          Return the Content Type associated with this Response.
 javax.servlet.http.Cookie[] getResponseCookies()
          Get the Cookies associated with this Response..
 long getResponseDateHeader(java.lang.String name)
           
 java.lang.String getResponseHeader(java.lang.String name)
          Get the Header with the specified name associated with this Response.
 java.util.Enumeration getResponseHeaderNames()
          Return the Header Names associated with this Response.
 java.util.Enumeration getResponseHeaders(java.lang.String name)
           
 int getResponseIntHeader(java.lang.String name)
           
 java.lang.String getScheme()
          Get the scheme of the URL used in this request, for example "http", "https", or "ftp".
 java.lang.String getServerName()
          Get the host name of the server that received the request.
 int getServerPort()
          Get the port number on which this request was received.
 boolean getSessionAffinity()
           
 boolean getSessionAffinityIdChangeRequest()
           
 int getStatus()
          Return the Status Type associated with this Response.
 java.io.PrintWriter getWriter()
          Gets a character stream printing writer for the response.
 boolean isCommitted()
          Returns a boolean indicating whether the response has been committed.
 boolean isSecure()
           
 java.lang.String maxAgeToExpires(int maxAge)
           
 java.util.Hashtable mergeParameters(java.util.Hashtable one, java.util.Hashtable two)
           
 java.util.Hashtable parsePostData(int len, javax.servlet.ServletInputStream in, java.lang.String encoding)
           
protected  void processCgiHeader(byte[] nameBytes, byte[] valueBytes)
          Abstract method to get authentication secret data.
protected  void processCookie(byte[] nameBytes, byte[] valueBytes)
          Abstract method to get authentication secret data.
protected  void processHttpHeader(byte[] nameBytes, byte[] valueBytes)
          Abstract method to get authentication secret data.
 void recycle()
           
 void removeAttribute(java.lang.String name)
          Remove attribute with the specified name
 void reset()
          Clears any data that exists in the buffer as well as the status code and headers.
 void resetBuffer()
           
 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 sendRedirect(java.lang.String location)
          Sends a temporary redirect response to the client using the specified redirect location URL.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set the Attribute with the specified name and value
 void setAuthData(java.lang.String authData)
          Sets authentication data.
 void setBufferSize(int size)
          Sets the preferred buffer size for the body of the response.
 void setCharacterEncoding(java.lang.String e)
           
 void setContentLength(int len)
          Sets the value of the outgoing Content-Length header.
 void setContentType(java.lang.String type)
          Sets the MIME content type of the outgoing response.
 void setDateHeader(java.lang.String name, long date)
          Sets a response header with the given name and date value.
 void setEnableLookups(boolean enable)
           
 void setHeader(java.lang.String name, java.lang.String value)
          Sets a response header with the given name and integer value.
 void setIntHeader(java.lang.String name, int value)
          Sets a response header with the given name and integer value.
 void setIPPortToken(java.lang.String ipPortToken)
          These values are used by the session manager to determine what IP and Port number to include with the user's session cookie.
 void setQueryString(java.lang.String queryString)
          Sets the query string that is part of the HTTP request URI.
 void setSessionAffinity(boolean sessionAffinity)
          This flag is used by the session manager to determine if the IP and Port string should be included in the session cookie.
 void setSessionAffinityIdChangeRequest(boolean newValue)
          If EnhydraDirector request to change ServerID this will be set to "true"
 void setStatus(int sc)
          Sets the status code for this response.
 void setStatus(int sc, java.lang.String sm)
          Sets the status code for this response.
 void setURIEncoding(java.lang.String URIEncoding)
           
 void setUseBodyEncodingForURI(boolean useBodyEncodingForURI)
           
protected  void stuffInternalHeader(java.lang.String name, java.lang.String value)
          Private helper method to stuff a header into the request headers list.
 
Methods inherited from class org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol
authenticate, authenticate, callback, closeConnection, connect, deactivate, discardEntity, finishHeaders, getStateName, getStateName, inputAvailable, isAuthenticated, isConnected, isOpen, read, read, read, readExactly, readExactly, sendCookie, sendHeader, skip, toString, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

public static final java.lang.String DEFAULT_ENCODING
See Also:
Constant Field Values

FORM_POST_MIME_TYPE

public static final java.lang.String FORM_POST_MIME_TYPE
Standard Mime type for POST-ed forms.

See Also:
Constant Field Values
Constructor Detail

EnhydraDirectorConnection

public EnhydraDirectorConnection()
                          throws java.io.IOException
Method Detail

setUseBodyEncodingForURI

public void setUseBodyEncodingForURI(boolean useBodyEncodingForURI)

setURIEncoding

public void setURIEncoding(java.lang.String URIEncoding)

getEnableLookups

public boolean getEnableLookups()

setEnableLookups

public void setEnableLookups(boolean enable)

getResponseCookies

public javax.servlet.http.Cookie[] getResponseCookies()
Get the Cookies associated with this Response..


setIPPortToken

public void setIPPortToken(java.lang.String ipPortToken)
These values are used by the session manager to determine what IP and Port number to include with the user's session cookie. This value default to null and is set by the EnhydraDirectorHandler.java


getIPPortToken

public java.lang.String getIPPortToken()

setSessionAffinity

public void setSessionAffinity(boolean sessionAffinity)
This flag is used by the session manager to determine if the IP and Port string should be included in the session cookie. This value defaults to true and is set by EnhydraDirectorHandler.java


getSessionAffinity

public boolean getSessionAffinity()

activate

public void activate()
              throws java.io.IOException
Override the activate() method to allow per-connection variables to be reset for each new connection.

Overrides:
activate in class EnhydraDirectorProtocol
Throws:
java.io.IOException - If an error occurs.

recycle

public void recycle()

getFunction

protected EnhydraDirectorFunction getFunction(int type)
Internal dispatch table for server side function handlers. Supported functions are permanently registered at compile time by placing them in this method's switch block.

Specified by:
getFunction in class EnhydraDirectorProtocol
Parameters:
type - Protocol-defined function type number.
Returns:
Reference to the appropriate function handler instance.

authRequired

protected boolean authRequired()
Implementation class must provide this method. It should check the configuration data to determine if authentication is required for connections.

Specified by:
authRequired in class EnhydraDirectorProtocol
Returns:
true if authentication is required.

getAuthData

protected byte[] getAuthData()
Abstract method to get authentication secret data.

This method must be provided by the implementation class. It checks the configuration and finds the secret authentication data used to verify authentication responses from clients.

Specified by:
getAuthData in class EnhydraDirectorProtocol
Returns:
A byte array of authentication data, or null if authentication data does not exist.

setAuthData

public void setAuthData(java.lang.String authData)
Sets authentication data.

This method allows the connection method handler to pass the configured authentication string to this instance for use in establishing connections.


processCgiHeader

protected void processCgiHeader(byte[] nameBytes,
                                byte[] valueBytes)
Abstract method to get authentication secret data.

Specified by:
processCgiHeader in class EnhydraDirectorProtocol
Returns:
A byte array of authentication data, or null if authentication data does not exist.

stuffInternalHeader

protected void stuffInternalHeader(java.lang.String name,
                                   java.lang.String value)
Private helper method to stuff a header into the request headers list.

If this is used to stuff 'pseudo' headers for internal code, then the headers should have illegal names that can't conflict with valid HTTP headers.

Parameters:
name - The header name.
Returns:
A byte array of authentication data, or null if authentication data does not exist.

processHttpHeader

protected void processHttpHeader(byte[] nameBytes,
                                 byte[] valueBytes)
Abstract method to get authentication secret data.

Specified by:
processHttpHeader in class EnhydraDirectorProtocol
Returns:
A byte array of authentication data, or null if authentication data does not exist.

processCookie

protected void processCookie(byte[] nameBytes,
                             byte[] valueBytes)
Abstract method to get authentication secret data.

Specified by:
processCookie in class EnhydraDirectorProtocol
Returns:
A byte array of authentication data, or null if authentication data does not exist.

getAuthType

public java.lang.String getAuthType()
Gets the authentication scheme of this request.

Returns:
This request's authentication scheme, or null if none.

getCookies

public javax.servlet.http.Cookie[] getCookies()
Gets the array of cookies found in this request.

Returns:
The array of cookies found in this request

getDateHeader

public long getDateHeader(java.lang.String name)
Gets the value of the requested date header field of this request.

Parameters:
name - the String containing the name of the requested header field. The comparison is case insensitive.
Returns:
the value the requested date header field, or -1 if not found.
Throws:
java.lang.IllegalArgumentException - If value of header can't be converted to an int.

getHeader

public java.lang.String getHeader(java.lang.String name)
Gets the value of the requested header field of this request.

Parameters:
name - The String containing the name of the requested header field. The comparison is case insensitive.
Returns:
The value of the requested header field, or null if not known.

getHeaderNames

public java.util.Enumeration getHeaderNames()
Gets the header names for this request.

Returns:
An enumeration of strings representing the header names for this request.

getHeaders

public java.util.Enumeration getHeaders(java.lang.String name)
Returns all the values of the specified requst header as an Enumeration of String objects.

Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.

If the request did not include any headers of the specified name, this method returns an empty Enumeration. The header name is case insensitive. You can use this method with any request header.

Parameters:
name - A String specifying the header name.
Returns:
An Enumeration containing the values of the requested header, or an empty Enumeration if the request does not have any headers of that name.

getIntHeader

public int getIntHeader(java.lang.String name)
                 throws java.lang.NumberFormatException
Gets the value of the specified integer header field of this request.

Parameters:
name - The String containing the name of the requested header field. The comparison is case insensitive.
Returns:
the value of the requested header field, or -1 if not found.
Throws:
java.lang.NumberFormatException - If value of header can't be converted to an int.

getMethod

public java.lang.String getMethod()
Gets the HTTP method (for example, GET, POST, PUT) with which this request was made.

Returns:
the HTTP method with which this request was made

getQueryString

public java.lang.String getQueryString()
Gets any query string that is part of the HTTP request URI.

Returns:
query string that is part of this request's URI, or null if it contains no query string

setQueryString

public void setQueryString(java.lang.String queryString)
Sets the query string that is part of the HTTP request URI. The querystring can be set by a RequestDispatcher forward.


getRemoteUser

public java.lang.String getRemoteUser()
Gets the name of the user making this request. The user name is set with HTTP authentication.

Returns:
The name of the user making this request, or null if not known.

getLocalPort

public int getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received.


getRemotePort

public int getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.


getLocalAddr

public java.lang.String getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the request was received.


getLocalName

public java.lang.String getLocalName()
Returns the host name of the Internet Protocol (IP) interface on which the request was received.


getRequestURI

public java.lang.String getRequestURI()
Get the part of this request's URI that is to the left of any query string.

Returns:
This request's URI
See Also:
HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the value of an attribute of the request.

Parameters:
name - The name of the attribute whose value is required.
Returns:
The value of the named attribute of the request, or null if the attribute does not exist.

getAttributeNames

public java.util.Enumeration getAttributeNames()

getContentLength

public int getContentLength()
Get the size of the request data.


getContentType

public java.lang.String getContentType()
Get the content type of the request.

Returns:
The Internet Media Type of the request entity data, or null if not known.

getInputStream

public javax.servlet.ServletInputStream getInputStream()
                                                throws java.io.IOException
Get an input stream for reading binary data in the request body.

Throws:
java.lang.IllegalStateException - if getReader has been called on this same request.
java.io.IOException - on other I/O related errors.
See Also:
getReader

getParameter

public java.lang.String getParameter(java.lang.String name)
Get a string containing the lone value of the specified parameter.

This call is case sensitive.

Parameters:
name - The name of the parameter whose value is required.
Returns:
The parameter value or null if the parameter does not exist.
See Also:
getParameterValues(java.lang.String)

getParameterNames

public java.util.Enumeration getParameterNames()
Get the parameter names for this request.

Returns:
The parameter names for this request as an enumeration.

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Get the values of the specified parameter for the request.

The name is case sensitive.

Parameters:
name - the name of the parameter whose value is required.
Returns:
The values of the specified parameter for the request as an array of strings, or null if the named parameter does not exist.
See Also:
ServletRequest.getParameter(java.lang.String)

getProtocol

public java.lang.String getProtocol()
Get the protocol and version of the request.

Returns:
The protocol and version of the request as a string of the form <protocol>/<major version>.<minor version>.

getReader

public java.io.BufferedReader getReader()
                                 throws java.io.IOException
Returns a buffered reader for reading text in the request body. This translates character set encodings as appropriate.

Returns:
A buffered reader object.
Throws:
UnsupportedEncodingException - if the character set encoding is unsupported, so the text can't be correctly decoded.
java.lang.IllegalStateException - if getInputStream has been called on this same request.
java.io.IOException - on other I/O related errors.
See Also:
getInputStream

getRemoteAddr

public java.lang.String getRemoteAddr()
Get the IP address of the agent that sent the request.


getInetAddress

public java.net.InetAddress getInetAddress()

getRemoteHost

public java.lang.String getRemoteHost()
Get the fully qualified host name of the agent that sent the request.

Returns:
The host name.

getScheme

public java.lang.String getScheme()
Get the scheme of the URL used in this request, for example "http", "https", or "ftp".

Returns:
The scheme of the URL.

getServerName

public java.lang.String getServerName()
Get the host name of the server that received the request.

Returns:
The host name.

getHost

public java.lang.String getHost()
Get the host name


getServerPort

public int getServerPort()
Get the port number on which this request was received.


isSecure

public boolean isSecure()

removeAttribute

public void removeAttribute(java.lang.String name)
Remove attribute with the specified name


setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Sets a response header with the given name and integer value.

If the header has 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.

Parameters:
name - The name of the header.
value - The value to assign.

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Adds a response header with the given name and integer value.

This method allows response headers to have multiple values.

Parameters:
name - The name of the header.
value - The value to assign.

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Add a cookie to the list of cookies to send to the browser.

Parameters:
cookie - The cookie to add.

containsHeader

public boolean containsHeader(java.lang.String name)
Returns true if the current response contains the named header.

Parameters:
name - The name of the header.
Returns:
whether the header is contained in the response.

encodeUrl

public java.lang.String encodeUrl(java.lang.String url)
Encodes the specified URL by including the session ID in it, or if encoding is not needed, returns the URL unchanged.

Returns:
The encoded URL if encoding is needed; the unchanged URL otherwise.

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String url)
Encodes the specified URL for use in the sendRedirect method.

Returns:
The encoded URL if encoding is needed; the unchanged URL otherwise.

getMessage

public java.lang.String getMessage()

sendError

public void sendError(int sc,
                      java.lang.String msg)
               throws java.io.IOException
Sends an error response to the client using the specified status code and descriptive message.

Parameters:
sc - The status code.
msg - The descriptive message.
Throws:
java.io.IOException - If an I/O error has occured.

sendError

public void sendError(int sc)
               throws java.io.IOException
Sends an error response to the client using the specified status code and a default message.

Parameters:
sc - The status code.
Throws:
java.io.IOException - If an I/O error has occured.

sendRedirect

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException
Sends a temporary redirect response to the client using the specified redirect location URL.

Parameters:
location - The redirect location URL.
Throws:
java.io.IOException - If an I/O error has occured.

setDateHeader

public void setDateHeader(java.lang.String name,
                          long date)
Sets a response header with the given name and date value.

If the header has 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.

Parameters:
name - The name of the header.

addDateHeader

public void addDateHeader(java.lang.String name,
                          long date)
Adds a response header with the given name and date value.

This method allows response headers to have multiple values.

Parameters:
name - The name of the header.

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
Sets a response header with the given name and integer value.

If the header has 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.

Parameters:
name - The name of the header.
value - The value to assign.

addIntHeader

public void addIntHeader(java.lang.String name,
                         int value)
Adds a response header with the given name and integer value.

This method allows response headers to have multiple values.

Parameters:
name - The name of the header.
value - The value to assign.

setStatus

public void setStatus(int sc,
                      java.lang.String sm)
Sets the status code for this response.

Parameters:
sc - The HTTP status code.
sm - Message to send with status code.

setStatus

public void setStatus(int sc)
Sets the status code for this response.

This method is used to set the return status code when there is no error. (For example, SC_OK or SC_MOVED_TEMPORARILY). If there is an error, the sendError method should be used instead.

Parameters:
sc - The status code.

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Returns the charset used for the body.


getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws java.io.IOException
Returns the byte output stream object for this response.

This method may not be called if it or getWriter() have already been called.

Returns:
The output stream.
Throws:
java.lang.IllegalStateException - If this method is called after the output stream has already been gotten.
java.io.IOException

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Gets a character stream printing writer for the response.

This implementation is not fully functional, since it uses the default character encoding instead of mapping the charset portion of the Content-Type to the correct encoding.

Returns:
A PrintWriter stream for output.
Throws:
java.io.IOException - If an I/O error occurs.
java.lang.IllegalStateException - If getOutputStream() already called.
UnsupportedEncodingException - If an unknown character encoding is specified.

setContentLength

public void setContentLength(int len)
Sets the value of the outgoing Content-Length header.

Sets the length of the outgoing content. Any data sent beyond this length will be discarded, and the output will be padded to this length after the output stream is closed. Padding is with octets of value 0 (zero).

Parameters:
len - The Content-Length value.

setContentType

public void setContentType(java.lang.String type)
Sets the MIME content type of the outgoing response.

FIXME XXX - This is not fully implemented. It simply copies the type verbatim to the MIME headers sent with the response. Future versions of this class may attempt to read the "charset" portion of the content type to determine which encoding, if any, should be used for streams returned by getWriter(). This will require a configuration table that maps locales, MIME charsets, and Java encodings.

Parameters:
type - The MIME type of this response.

setBufferSize

public void setBufferSize(int size)
Sets the preferred buffer size for the body of the response.

The servlet container will use a buffer at least as large as the size requested. The actual buffer size used can be found using getBufferSize.

A larger buffer allows more content to be written before anything is actually sent, this providing the servlet with more time to set appropriate status codes and headers. A smaller buffer decreases server memory load and allows the client to start receiving data more quickly.

This method must be called before any response body content is written; if content has been written, this method throws an IllegalStateException.

Parameters:
size - The preferred buffer size.
Throws:
java.lang.IllegalStateException - If called after content written.

getBufferSize

public int getBufferSize()
Returns the actual buffer size used for the response.

If no buffering is used, this method returns 0.

Returns:
The size of the send buffer.

isCommitted

public boolean isCommitted()
Returns a boolean indicating whether the response has been committed.

A committed response has already had its status code and headers written.

Returns:
A boolean indicating if the response has been committed.

reset

public void reset()
           throws java.lang.IllegalStateException
Clears any data that exists in the buffer as well as the status code and headers. If the response has been commited, this method throws an IllegalStateException.

Throws:
java.lang.IllegalStateException - If the response has already been committed.

encodeURL

public java.lang.String encodeURL(java.lang.String url)
mora servlet response Sets the locale of the response.

This is supposed to set the headers, including Content-Type and Content-Encoding. However, it is not * clear how to map between character encodings and locales.

Probably, future revisions of this class will use some sort of mapping table to set the encodings. For now, it just keeps track of which locale is set and uses Latin1 encoding in the underlying output stream. Servlets that want to use other encodings should create an appropriate PrintWriter on the binary stream given by getOutputStream. XXX - FIXME.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Set the Attribute with the specified name and value


encodeRedirectURL

public java.lang.String encodeRedirectURL(java.lang.String url)

resetBuffer

public void resetBuffer()

setCharacterEncoding

public void setCharacterEncoding(java.lang.String e)

getResponseHeader

public java.lang.String getResponseHeader(java.lang.String name)
Get the Header with the specified name associated with this Response.


getResponseHeaderNames

public java.util.Enumeration getResponseHeaderNames()
Return the Header Names associated with this Response.


getResponseIntHeader

public int getResponseIntHeader(java.lang.String name)

getResponseDateHeader

public long getResponseDateHeader(java.lang.String name)

getResponseHeaders

public java.util.Enumeration getResponseHeaders(java.lang.String name)

getStatus

public int getStatus()
Return the Status Type associated with this Response.


getResponseContentType

public java.lang.String getResponseContentType()
Return the Content Type associated with this Response.


getResponseContentLength

public int getResponseContentLength()
Return the Content Length associated with this Response.


getRequestURL

public java.lang.StringBuffer getRequestURL()
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Because this method returns a StringBuffer, not a string, you can modify the URL easily, for example, to append query parameters.

This method is useful for creating redirect messages and for reporting errors.

Returns:
a StringBuffer object containing the reconstructed URL

mergeParameters

public java.util.Hashtable mergeParameters(java.util.Hashtable one,
                                           java.util.Hashtable two)

doWrite

public void doWrite(byte[] buffer,
                    int pos,
                    int count)
             throws java.io.IOException
Write a chunk of bytes. Should be called only from ServletOutputStream implementations, No need to implement it if your adapter implements ServletOutputStream. Headers and status will be written before this method is exceuted.

Throws:
java.io.IOException

closeOutput

public void closeOutput()
                 throws java.io.IOException
Description copied from class: EnhydraDirectorProtocol
Method to close output stream.

Overrides:
closeOutput in class EnhydraDirectorProtocol
Throws:
java.io.IOException

closeInput

public void closeInput()
                throws java.io.IOException
Description copied from class: EnhydraDirectorProtocol
Discards any further incoming request entity data and marks the input stream as "closed".

Overrides:
closeInput in class EnhydraDirectorProtocol
Throws:
java.io.IOException - if an error occurs while discarding entity data. This usually will cause the protocol to go out of sync.

flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Forces any content in the buffer to be written to the client.

A call to this method automatically commits the response, meaning the status code and headers will be written.

Throws:
java.io.IOException - If an I/O error occurs.

setSessionAffinityIdChangeRequest

public void setSessionAffinityIdChangeRequest(boolean newValue)
If EnhydraDirector request to change ServerID this will be set to "true"

Parameters:
newValue - The sessionAffinityIdChangeRequest to set.

getSessionAffinityIdChangeRequest

public boolean getSessionAffinityIdChangeRequest()

formatResponseCookie

public java.lang.String formatResponseCookie(javax.servlet.http.Cookie cookie)

maxAgeToExpires

public java.lang.String maxAgeToExpires(int maxAge)

parsePostData

public java.util.Hashtable parsePostData(int len,
                                         javax.servlet.ServletInputStream in,
                                         java.lang.String encoding)