|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectro.polak.littleServlet.HTTPResponse
public class HTTPResponse
Represents HTTP response
Java Little Web Server Homepage
| Constructor Summary | |
|---|---|
HTTPResponse(java.net.Socket socket)
Class constructor |
|
| Method Summary | |
|---|---|
void |
close()
Closes the socket |
void |
flush()
Flushes the output |
boolean |
flushHeaders()
Flushes headers, returns false when headers already flushed |
HTTPResponseHeaders |
getHeaders()
|
PrintWriter |
getPrintWriter()
Returns request's print writer |
boolean |
isCommitted()
Returns a boolean indicating if the response has been committed. |
void |
sendRedirect(java.lang.String location)
Redirects the request to the specified location. |
void |
serveFile(java.io.File file)
Flushes headers and serves the specified file |
void |
setContentLength(int length)
Sets content length |
void |
setContentLength(long length)
Sets content length |
void |
setContentType(java.lang.String contentType)
Sets content type |
void |
setCookie(java.lang.String cookieName,
java.lang.String cookieValue)
Sets cookie, expires when browser closed |
void |
setCookie(java.lang.String cookieName,
java.lang.String cookieValue,
int cookieExpiresSeconds)
Sets cookie Use negative time to remove cookie |
void |
setCookie(java.lang.String cookieName,
java.lang.String cookieValue,
int cookieExpiresSeconds,
java.lang.String cookiePath)
Sets cookie |
void |
setHeader(java.lang.String headerName,
java.lang.String headerValue)
Sets header |
void |
setKeepAlive(boolean keepAlive)
Sets keepAlive |
void |
setStatus(java.lang.String status)
Sets status of response |
void |
write(byte[] byteArray)
Writes byte array to the output |
void |
write(java.lang.String s)
Writes string to the output |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HTTPResponse(java.net.Socket socket)
socket - - socket to be written| Method Detail |
|---|
public void write(byte[] byteArray)
byteArray - byte arraypublic void write(java.lang.String s)
s - String to be written
public void setCookie(java.lang.String cookieName,
java.lang.String cookieValue,
int cookieExpiresSeconds,
java.lang.String cookiePath)
cookieName - name of the cookiecookieValue - String value of the cookiecookieExpiresSeconds - expire time in secondscookiePath - path for the cookie
public void setCookie(java.lang.String cookieName,
java.lang.String cookieValue)
cookieName - name of the cookiecookieValue - String value of the cookie
public void setCookie(java.lang.String cookieName,
java.lang.String cookieValue,
int cookieExpiresSeconds)
Use negative time to remove cookie
cookieName - name of the cookiecookieValue - String value of the cookiecookieExpiresSeconds - expire time in secondspublic boolean flushHeaders()
public boolean isCommitted()
public void flush()
throws java.io.IOException
java.io.IOExceptionpublic void sendRedirect(java.lang.String location)
location - - relative or absolute path (URL)public void serveFile(java.io.File file)
file - file to be servedpublic void setContentType(java.lang.String contentType)
contentType - content type
public void setHeader(java.lang.String headerName,
java.lang.String headerValue)
headerName - name of the headerheaderValue - value of the headerpublic void setKeepAlive(boolean keepAlive)
keepAlive - true for keep alive connectionpublic void setContentLength(int length)
length - length of contentpublic void setContentLength(long length)
length - length of contentpublic HTTPResponseHeaders getHeaders()
public void setStatus(java.lang.String status)
status - status code and message
public void close()
throws java.io.IOException
java.io.IOExceptionpublic PrintWriter getPrintWriter()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||