kom.tools.web
Class HTTPResponse

java.lang.Object
  |
  +--kom.tools.web.HTTPResponse
Direct Known Subclasses:
GETResponse, POSTResponse

public abstract class HTTPResponse
extends java.lang.Object

Definition of an HTTP requestHandler


Field Summary
static java.lang.String APPLICATION_URLENCODED
           
(package private)  java.lang.String boundary
           
static java.lang.String BOUNDARY
           
protected  boolean broke
           
 boolean close
           
protected  HTTPConfig config
           
(package private)  java.lang.String contentType
           
protected  java.lang.String cursor
           
 java.io.File fileToDelete
           
(package private)  Gateway gateway
           
 java.lang.String header
           
(package private)  javax.servlet.ServletInputStream in
           
(package private)  int len
           
 java.lang.String method
           
(package private)  boolean newSession
           
(package private)  javax.servlet.ServletOutputStream out
           
protected  java.util.Hashtable pairs
           
 java.lang.String protocol
           
protected  java.lang.String reasonPhrase
           
 javax.servlet.http.HttpServletRequest request
           
 javax.servlet.http.HttpServletResponse response
           
(package private)  int sendBytes
           
protected  java.lang.String servletBase
           
 javax.servlet.http.HttpSession session
           
 java.lang.String sessionId
           
protected  int statusCode
           
protected  java.lang.String tmpFile
           
 java.util.Hashtable upload
           
 java.lang.String uri
           
 
Constructor Summary
HTTPResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Gateway gateway, HTTPConfig config)
          Class constructor
 
Method Summary
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a response header
 java.lang.String get(java.lang.String name)
          Gets the value of a parameter contained in the query string.
 javax.servlet.http.HttpSession getHttpSession()
          Gets current HttpSession
abstract  java.io.InputStream getResponseData()
          Assembles response data, returning it as an InputStream
 java.lang.String[] getValues(java.lang.String name)
          Gets values for name (from pairs) as a String[]
 java.util.Enumeration names()
          Returns all parameter names in the query string or form
 void parseURI(java.lang.String r)
          Parses a URI query string for name/value pairs.
 void processRequest()
          Processes the request, sending the response to the client
 void put(java.lang.String param, int value)
          Puts param=int value in pairs table
 void put(java.lang.String param, java.lang.String value)
          Puts param=value in pairs table if both are non-null
 boolean readRequest()
          Reads and classifies data from request.
 void setCookie(java.lang.String name, java.lang.String value)
           
 void setPhrase(java.lang.String phrase)
          Sets reason phrase for response
 void setStatus(int status)
          Sets response status code
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

APPLICATION_URLENCODED

public static final java.lang.String APPLICATION_URLENCODED

BOUNDARY

public static final java.lang.String BOUNDARY

method

public java.lang.String method

uri

public java.lang.String uri

protocol

public java.lang.String protocol

header

public java.lang.String header

upload

public java.util.Hashtable upload

pairs

protected java.util.Hashtable pairs

tmpFile

protected java.lang.String tmpFile

contentType

java.lang.String contentType

boundary

java.lang.String boundary

len

int len

request

public javax.servlet.http.HttpServletRequest request

session

public javax.servlet.http.HttpSession session

sessionId

public java.lang.String sessionId

in

javax.servlet.ServletInputStream in

out

javax.servlet.ServletOutputStream out

response

public javax.servlet.http.HttpServletResponse response

config

protected HTTPConfig config

broke

protected boolean broke

close

public boolean close

statusCode

protected int statusCode

reasonPhrase

protected java.lang.String reasonPhrase

cursor

protected java.lang.String cursor

servletBase

protected java.lang.String servletBase

sendBytes

int sendBytes

newSession

boolean newSession

gateway

Gateway gateway

fileToDelete

public java.io.File fileToDelete
Constructor Detail

HTTPResponse

public HTTPResponse(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response,
                    Gateway gateway,
                    HTTPConfig config)
             throws javax.servlet.ServletException,
                    java.io.IOException,
                    java.lang.IllegalArgumentException
Class constructor
Parameters:
request - HTTP request
response - HTTP response
gateway - Client supervisor
config - Configuration data
Throws:
ServletException, - IOException, IllegalArgumentException
Method Detail

readRequest

public boolean readRequest()
Reads and classifies data from request. Determines contentType, boundary, len, tmpFile
Returns:
true on success

setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value)

getHttpSession

public javax.servlet.http.HttpSession getHttpSession()
Gets current HttpSession
Returns:
HttpSession or null

setStatus

public void setStatus(int status)
Sets response status code
Parameters:
status - Status code to be set

setPhrase

public void setPhrase(java.lang.String phrase)
Sets reason phrase for response
Parameters:
phrase - Explains the reason for the return code

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Adds a response header
Parameters:
name - Header name
value - Header value

put

public void put(java.lang.String param,
                java.lang.String value)
Puts param=value in pairs table if both are non-null
Parameters:
name - Key to value
value - Value string

put

public void put(java.lang.String param,
                int value)
Puts param=int value in pairs table
Parameters:
name - Key to value
value - int value

get

public java.lang.String get(java.lang.String name)
Gets the value of a parameter contained in the query string.
Parameters:
name - the name of the query parameter to retrieve
Returns:
the value of the parameter

getValues

public java.lang.String[] getValues(java.lang.String name)
Gets values for name (from pairs) as a String[]
Parameters:
name - Key
Returns:
String array of values for the key

names

public java.util.Enumeration names()
Returns all parameter names in the query string or form
Returns:
All keys as an Enumeration

getResponseData

public abstract java.io.InputStream getResponseData()
Assembles response data, returning it as an InputStream
Returns:
InputStream for response

processRequest

public void processRequest()
Processes the request, sending the response to the client

parseURI

public void parseURI(java.lang.String r)
Parses a URI query string for name/value pairs. Puts result in pairs Hashtable
Parameters:
r - The input String