org.enhydra.servlet.connectionMethods.EnhydraDirector
Class EnhydraDirectorConnection

java.lang.Object
  extended byorg.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol
      extended byorg.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorConnection
All Implemented Interfaces:
java.util.Enumeration, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletRequest, javax.servlet.ServletResponse

public class EnhydraDirectorConnection
extends EnhydraDirectorProtocol
implements javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.Enumeration


Field Summary
static java.lang.String DEFAULT_ENCODING
           
static java.lang.String FORM_POST_MIME_TYPE
          Standard Mime type for POST-ed forms.
protected  org.apache.tomcat.util.http.mapper.MappingData mappingData
           
protected  org.apache.catalina.util.ParameterMap parameterMap
           
protected  org.apache.catalina.Session session
          The currently active session for this request.
 
Fields inherited from class org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorProtocol
active, clientMajor, clientMinor, log, 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
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
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
EnhydraDirectorConnection(org.apache.commons.logging.Log chan)
           
 
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 closeOutput()
          Method to close output stream.
protected  void configureSessionCookie(javax.servlet.http.Cookie cookie)
           
 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)
           
 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()
           
 int getContentLength()
          Get the size of the request data.
 java.lang.String getContentType()
          Get the content type of the request.
 org.apache.catalina.Context getContext()
          Get the Context
 java.lang.String getContextPath()
          Get the Context Path
 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.
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
 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.util.Locale getLocale()
          Gets the locale of the response.
 java.util.Enumeration getLocales()
           
 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.
 org.apache.tomcat.util.http.mapper.MappingData getMappingData()
          Get the Mapping Data
 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.Map getParameterMap()
          Returns a java.util.Map of the parameters of this request.
 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 getPathInfo()
          Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string.
 java.lang.String getPathTranslated()
          Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string, and translates it to a real path.
 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 getRealPath(java.lang.String path)
          Applies alias rules to the specified virtual path and returns the corresponding real path, or null if the translation can not be performed for any reason.
 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.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
           
 java.lang.String getRequestedSessionId()
          Gets the session id specified with 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..
 java.lang.String getResponseHeader(java.lang.String name)
          Get the Header with the specified name associated with this Response.
 java.lang.String[] getResponseHeaderNames()
          Return the Header Names associated with this Response.
 java.lang.String[] getResponseHeaderValues()
          Return the Header Values associated with this Response.
 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.
 java.lang.String getServletPath()
          Gets the part of this request's URI that refers to the servlet being invoked.
 javax.servlet.http.HttpSession getSession()
          Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request, if create is true.
 javax.servlet.http.HttpSession getSession(boolean create)
           
 boolean getSessionAffinity()
           
 int getStatus()
          Return the Status Type associated with this Response.
 java.security.Principal getUserPrincipal()
           
 org.apache.catalina.Wrapper getWrapper()
          Get the Wrapper within which this Request is being processed.
 java.io.PrintWriter getWriter()
          Gets a character stream printing writer for the response.
 boolean hasMoreElements()
          Stub hasMoreElements implementation so this instance can be passed as an empty enumeration.
 boolean isCommitted()
          Returns a boolean indicating whether the response has been committed.
 boolean isRequestedSessionIdFromCookie()
          Checks whether the session id specified by this request came in as a cookie.
 boolean isRequestedSessionIdFromUrl()
          Checks whether the session id specified by this request came in as part of the URL.
 boolean isRequestedSessionIdFromURL()
          Checks whether the session id specified by this request came in as part of the URL.
 boolean isRequestedSessionIdValid()
          Checks whether this request is associated with a session that is valid in the current session context.
 boolean isSecure()
           
 boolean isUserInRole(java.lang.String role)
          Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
 java.lang.String maxAgeToExpires(int maxAge)
           
 java.util.Hashtable mergeParameters(java.util.Hashtable one, java.util.Hashtable two)
           
 java.lang.Object nextElement()
          Stub nextElement implementation so this instance can be passed as an empty enumeration.
 void obtainSessionId()
           
 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)
          Set attribute with the specified name
 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 setContext(org.apache.catalina.Context context)
          Set the Context
 void setDateHeader(java.lang.String name, long date)
          Sets a response header with the given name and date value.
 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 setLocale(java.util.Locale loc)
          mora servlet response Sets the locale of the response.
 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 setUserPrincipal(java.security.Principal principal)
           
 void setWrapper(org.apache.catalina.Wrapper wrapper)
          Set the Wrapper within which this Request is being processed.
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, closeInput, 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

session

protected org.apache.catalina.Session session
The currently active session for this request.


parameterMap

protected org.apache.catalina.util.ParameterMap parameterMap

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

mappingData

protected org.apache.tomcat.util.http.mapper.MappingData mappingData
Constructor Detail

EnhydraDirectorConnection

public EnhydraDirectorConnection(org.apache.commons.logging.Log chan)
                          throws java.io.IOException
Method Detail

getMappingData

public org.apache.tomcat.util.http.mapper.MappingData getMappingData()
Get the Mapping Data


getWrapper

public org.apache.catalina.Wrapper getWrapper()
Get the Wrapper within which this Request is being processed.


setWrapper

public void setWrapper(org.apache.catalina.Wrapper wrapper)
Set the Wrapper within which this Request is being processed.


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.

hasMoreElements

public boolean hasMoreElements()
Stub hasMoreElements implementation so this instance can be passed as an empty enumeration.

This is necessary because Enumeration cannot be instantiated by itself, and some methods in this class must return an empty enumeration if certain headers or parameters are not found.

Specified by:
hasMoreElements in interface java.util.Enumeration
Returns:
Always returns false, indicating no more elements are in this enumeration.

nextElement

public java.lang.Object nextElement()
                             throws java.util.NoSuchElementException
Stub nextElement implementation so this instance can be passed as an empty enumeration.

This is necessary because Enumeration cannot be instantiated by itself, and some methods in this class must return an empty enumeration if certain headers or parameters are not found.

Specified by:
nextElement in interface java.util.Enumeration
Returns:
Normally an Object, but in this case it only throws exceptions.
Throws:
java.util.NoSuchElementException - Always.

getAuthType

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

Specified by:
getAuthType in interface javax.servlet.http.HttpServletRequest
Returns:
This request's authentication scheme, or null if none.

getContextPath

public java.lang.String getContextPath()
Get the Context Path

Specified by:
getContextPath in interface javax.servlet.http.HttpServletRequest

getContext

public org.apache.catalina.Context getContext()
Get the Context


setContext

public void setContext(org.apache.catalina.Context context)
Set the Context


getCookies

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

Specified by:
getCookies in interface javax.servlet.http.HttpServletRequest
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.

Specified by:
getDateHeader in interface javax.servlet.http.HttpServletRequest
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.

Specified by:
getHeader in interface javax.servlet.http.HttpServletRequest
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.

Specified by:
getHeaderNames in interface javax.servlet.http.HttpServletRequest
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.

Specified by:
getHeaders in interface javax.servlet.http.HttpServletRequest
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.

Specified by:
getIntHeader in interface javax.servlet.http.HttpServletRequest
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.

Specified by:
getMethod in interface javax.servlet.http.HttpServletRequest
Returns:
the HTTP method with which this request was made

getPathInfo

public java.lang.String getPathInfo()
Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string.

Specified by:
getPathInfo in interface javax.servlet.http.HttpServletRequest
Returns:
The optional path information following the servlet path, but before the query string, in this request's URI; null if this request's URI contains no extra path information.

getPathTranslated

public java.lang.String getPathTranslated()
Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string, and translates it to a real path.

Specified by:
getPathTranslated in interface javax.servlet.http.HttpServletRequest
Returns:
Extra path information translated to a real path or null if no extra path information is in the request's URI.

getQueryString

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

Specified by:
getQueryString in interface javax.servlet.http.HttpServletRequest
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.

Specified by:
getRemoteUser in interface javax.servlet.http.HttpServletRequest
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.

Specified by:
getLocalPort in interface javax.servlet.ServletRequest

getRemotePort

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

Specified by:
getRemotePort in interface javax.servlet.ServletRequest

getLocalAddr

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

Specified by:
getLocalAddr in interface javax.servlet.ServletRequest

getLocalName

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

Specified by:
getLocalName in interface javax.servlet.ServletRequest

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Gets the session id specified with this request.

Specified by:
getRequestedSessionId in interface javax.servlet.http.HttpServletRequest
Returns:
The session id specified by this request, or null if the request did not specify a session id.
See Also:
isRequestedSessionIdValid()

getRequestURI

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

Specified by:
getRequestURI in interface javax.servlet.http.HttpServletRequest
Returns:
This request's URI
See Also:
HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)

getServletPath

public java.lang.String getServletPath()
Gets the part of this request's URI that refers to the servlet being invoked.

Specified by:
getServletPath in interface javax.servlet.http.HttpServletRequest
Returns:
The servlet being invoked, as contained in this request's URI.

getSession

public javax.servlet.http.HttpSession getSession()
Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request, if create is true.

Specified by:
getSession in interface javax.servlet.http.HttpServletRequest
Returns:
The session associated with this request or null if create was false and no valid session is associated with this request.

obtainSessionId

public void obtainSessionId()

getSession

public javax.servlet.http.HttpSession getSession(boolean create)
Specified by:
getSession in interface javax.servlet.http.HttpServletRequest

configureSessionCookie

protected void configureSessionCookie(javax.servlet.http.Cookie cookie)

getUserPrincipal

public java.security.Principal getUserPrincipal()
Specified by:
getUserPrincipal in interface javax.servlet.http.HttpServletRequest

setUserPrincipal

public void setUserPrincipal(java.security.Principal principal)

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Checks whether the session id specified by this request came in as a cookie.

Specified by:
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequest
Returns:
True if the session id specified by this request came in as a cookie; false otherwise.
See Also:
getSession()

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()
Checks whether the session id specified by this request came in as part of the URL.

Specified by:
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequest
Returns:
True if the session id specified by the request for this session came in as part of the URL; false otherwise.
See Also:
getSession()

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()
Checks whether the session id specified by this request came in as part of the URL.

Specified by:
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequest
Returns:
True if the session id specified by the request for this session came in as part of the URL; false otherwise.
See Also:
getSession()

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Checks whether this request is associated with a session that is valid in the current session context.

Specified by:
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequest
Returns:
True if this request is assocated with a session that is valid in the current session context.
See Also:
getRequestedSessionId(), HttpSessionContext, getSession()

isUserInRole

public boolean isUserInRole(java.lang.String role)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.

Specified by:
isUserInRole in interface javax.servlet.http.HttpServletRequest
Parameters:
role - a String specifying the name of the role
Returns:
a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated

getAttribute

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

Specified by:
getAttribute in interface javax.servlet.ServletRequest
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()
Specified by:
getAttributeNames in interface javax.servlet.ServletRequest

getContentLength

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

Specified by:
getContentLength in interface javax.servlet.ServletRequest

getContentType

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

Specified by:
getContentType in interface javax.servlet.ServletRequest
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.

Specified by:
getInputStream in interface javax.servlet.ServletRequest
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

getLocales

public java.util.Enumeration getLocales()
Specified by:
getLocales in interface javax.servlet.ServletRequest

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.

Specified by:
getParameter in interface javax.servlet.ServletRequest
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.

Specified by:
getParameterNames in interface javax.servlet.ServletRequest
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.

Specified by:
getParameterValues in interface javax.servlet.ServletRequest
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.

Specified by:
getProtocol in interface javax.servlet.ServletRequest
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.

Specified by:
getReader in interface javax.servlet.ServletRequest
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

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Applies alias rules to the specified virtual path and returns the corresponding real path, or null if the translation can not be performed for any reason.

Specified by:
getRealPath in interface javax.servlet.ServletRequest
Parameters:
path - The virtual path to be translated to a real path.
Returns:
The real path.

getRemoteAddr

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

Specified by:
getRemoteAddr in interface javax.servlet.ServletRequest

getRemoteHost

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

Specified by:
getRemoteHost in interface javax.servlet.ServletRequest
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".

Specified by:
getScheme in interface javax.servlet.ServletRequest
Returns:
The scheme of the URL.

getServerName

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

Specified by:
getServerName in interface javax.servlet.ServletRequest
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.

Specified by:
getServerPort in interface javax.servlet.ServletRequest

isSecure

public boolean isSecure()
Specified by:
isSecure in interface javax.servlet.ServletRequest

removeAttribute

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

Specified by:
removeAttribute in interface javax.servlet.ServletRequest

setAttribute

public void setAttribute(java.lang.String name)
Set 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.

Specified by:
setHeader in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
addHeader in interface javax.servlet.http.HttpServletResponse
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.

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

containsHeader

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

Specified by:
containsHeader in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
encodeUrl in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
sendRedirect in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
setDateHeader in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
addDateHeader in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
setIntHeader in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
addIntHeader in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse
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.

Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse
Parameters:
sc - The status code.

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Specified by:
getCharacterEncoding in interface javax.servlet.ServletRequest

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.

Specified by:
getOutputStream in interface javax.servlet.ServletResponse
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.

Specified by:
getWriter in interface javax.servlet.ServletResponse
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).

Specified by:
setContentLength in interface javax.servlet.ServletResponse
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.

Specified by:
setContentType in interface javax.servlet.ServletResponse
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.

Specified by:
setBufferSize in interface javax.servlet.ServletResponse
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.

Specified by:
getBufferSize in interface javax.servlet.ServletResponse
Returns:
The size of the send buffer.

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.

Specified by:
flushBuffer in interface javax.servlet.ServletResponse
Throws:
java.io.IOException - If an I/O error occurs.

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.

Specified by:
isCommitted in interface javax.servlet.ServletResponse
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.

Specified by:
reset in interface javax.servlet.ServletResponse
Throws:
java.lang.IllegalStateException - If the response has already been committed.

setLocale

public void setLocale(java.util.Locale loc)
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.

Specified by:
setLocale in interface javax.servlet.ServletResponse
Parameters:
loc - The local set for output on this response.

getLocale

public java.util.Locale getLocale()
Gets the locale of the response.

Locale is supposed to determine some attributes of headers, including Content-Type and Content-Encoding. Unfortunately, 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.

Specified by:
getLocale in interface javax.servlet.ServletRequest
Returns:
The local set for output on this response.

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
Specified by:
getRequestDispatcher in interface javax.servlet.ServletRequest

encodeURL

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

setAttribute

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

Specified by:
setAttribute in interface javax.servlet.ServletRequest

encodeRedirectURL

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

resetBuffer

public void resetBuffer()
Specified by:
resetBuffer in interface javax.servlet.ServletResponse

setCharacterEncoding

public void setCharacterEncoding(java.lang.String e)
Specified by:
setCharacterEncoding in interface javax.servlet.ServletRequest

getParameterMap

public java.util.Map getParameterMap()
Returns a java.util.Map of the parameters of this request. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

Specified by:
getParameterMap in interface javax.servlet.ServletRequest
Returns:
an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.

getResponseHeader

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


getResponseHeaderNames

public java.lang.String[] getResponseHeaderNames()
Return the Header Names associated with this Response.


getResponseHeaderValues

public java.lang.String[] getResponseHeaderValues()
Return the Header Values associated with this Response.


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.

Specified by:
getRequestURL in interface javax.servlet.http.HttpServletRequest
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
Method to close output stream. Overrides protocol engine's closeOutput to add a commit().

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

setSessionAffinityIdChangeRequest

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

Parameters:
newValue - The sessionAffinityIdChangeRequest to set.

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)