|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openejb.webadmin.httpd.HttpResponseImpl
public class HttpResponseImpl
This class takes care of HTTP Responses. It sends data back to the browser.
| Field Summary | |
|---|---|
static java.lang.String |
CRLF
a line feed character |
static java.lang.String |
CSP
a colon and space |
static java.lang.String |
HTTP_VERSION
the HTTP version |
static java.lang.String |
server
the server to send data from |
static java.lang.String |
SP
a space character |
| Constructor Summary | |
|---|---|
protected |
HttpResponseImpl()
creates a new instance of HttpResponseImpl with default values |
protected |
HttpResponseImpl(int code,
java.lang.String responseString,
java.lang.String contentType)
Creates a new HttpResponseImpl with user provided parameters |
| Method Summary | |
|---|---|
protected static HttpResponseImpl |
createError(java.lang.String message)
This could be improved at some day in the future to also include a stack trace of the exceptions |
protected static HttpResponseImpl |
createError(java.lang.String message,
java.lang.Throwable t)
creates an error with user defined variables |
protected static HttpResponseImpl |
createForbidden(java.lang.String ip)
Creates a forbidden response to be sent to the browser using IP authentication |
int |
getCode()
gets the HTTP response code |
java.lang.String |
getContentType()
gets the content type that will be sent to the browser |
java.lang.String |
getHeader(java.lang.String name)
Gets a header based on the name passed in |
java.io.OutputStream |
getOutputStream()
gets the OutputStream to send data to the browser |
java.io.PrintWriter |
getPrintWriter()
Gets the PrintWriter to send data to the browser |
java.lang.String |
getResponseString()
Sets the response string to be sent to the browser |
java.lang.String |
getServerName()
gets the name of the server being used |
void |
reset()
resets the data to be sent to the browser |
void |
reset(int code,
java.lang.String responseString)
resets the data to be sent to the browser with the response code and response string |
void |
setCode(int code)
sets the HTTP response code to be sent to the browser. |
void |
setContent(java.net.URLConnection content)
|
void |
setContentType(java.lang.String type)
sets the content type to be sent back to the browser |
void |
setHeader(java.lang.String name,
java.lang.String value)
sets a header to be sent back to the browser |
protected void |
setRequest(HttpRequestImpl request)
|
void |
setResponseString(java.lang.String responseString)
Sets the response string to be sent to the browser |
java.lang.String |
toString()
Creates a string version of the response similar to: HTTP/1.1 200 OK |
protected void |
writeMessage(java.io.OutputStream output)
Takes care of sending the response line, headers and body HTTP/1.1 200 OK Server: Netscape-Enterprise/3.6 SP3 Date: Thu, 07 Jun 2001 17:30:42 GMT Content-Type: text/html Connection: close |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String HTTP_VERSION
public static final java.lang.String CRLF
public static final java.lang.String SP
public static final java.lang.String CSP
public static java.lang.String server
| Constructor Detail |
|---|
protected HttpResponseImpl()
protected HttpResponseImpl(int code,
java.lang.String responseString,
java.lang.String contentType)
code - the HTTP Response code, see http://www.ietf.org/rfc/rfc2616.txt
for these codesresponseString - the response string to be sent backcontentType - the content type to be sent back| Method Detail |
|---|
protected void setRequest(HttpRequestImpl request)
public void setHeader(java.lang.String name,
java.lang.String value)
setHeader in interface HttpResponsename - the name of the headervalue - the value of the headerpublic java.lang.String getHeader(java.lang.String name)
getHeader in interface HttpResponsename - The name of the header
public java.io.PrintWriter getPrintWriter()
getPrintWriter in interface HttpResponsepublic java.io.OutputStream getOutputStream()
getOutputStream in interface HttpResponsepublic void setCode(int code)
setCode in interface HttpResponsecode - the code to be sent to the browserpublic int getCode()
getCode in interface HttpResponsepublic void setContentType(java.lang.String type)
setContentType in interface HttpResponsetype - the type to be sent to the browser (i.e. "text/html")public java.lang.String getContentType()
getContentType in interface HttpResponsepublic void setResponseString(java.lang.String responseString)
setResponseString in interface HttpResponseresponseString - the response stringpublic java.lang.String getResponseString()
public void reset()
reset in interface HttpResponse
public void reset(int code,
java.lang.String responseString)
reset in interface HttpResponsecode - the code to be sent to the browserresponseString - the response string to be sent to the browser
protected void writeMessage(java.io.OutputStream output)
throws java.io.IOException
output - the output to send the response to
java.io.IOException - if an exception is thrownpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getServerName()
getServerName in interface HttpResponseprotected static HttpResponseImpl createError(java.lang.String message)
message - the error message to be sent
protected static HttpResponseImpl createError(java.lang.String message,
java.lang.Throwable t)
message - the message of the errort - a Throwable to print a stack trace to
protected static HttpResponseImpl createForbidden(java.lang.String ip)
ip - the ip that is forbidden
public void setContent(java.net.URLConnection content)
content - The content to set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||