|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
rup.robot.httpserver.response
Class MyHttpServletResponse
java.lang.Object | +--rup.robot.httpserver.response.MyResponse | +--rup.robot.httpserver.response.MyHttpServletResponse
- Direct Known Subclasses:
- RupHttpResponse, SendRupRequest
- public class MyHttpServletResponse
- extends MyResponse
- implements javax.servlet.http.HttpServletResponse
- extends MyResponse
Permet de formuler une réponse conforme au protocole http
Fields inherited from class rup.robot.httpserver.response.MyResponse |
headers_out,
out |
Fields inherited from interface javax.servlet.http.HttpServletResponse |
SC_ACCEPTED,
SC_BAD_GATEWAY,
SC_BAD_REQUEST,
SC_CONFLICT,
SC_CONTINUE,
SC_CREATED,
SC_FORBIDDEN,
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_RESET_CONTENT,
SC_SEE_OTHER,
SC_SERVICE_UNAVAILABLE,
SC_SWITCHING_PROTOCOLS,
SC_UNAUTHORIZED,
SC_UNSUPPORTED_MEDIA_TYPE,
SC_USE_PROXY |
Constructor Summary | |
MyHttpServletResponse(java.io.OutputStream out)
|
Method Summary | |
void |
addCookie(javax.servlet.http.Cookie cookie)
PAS IMPLEMENTE ,PAS IMPLEMENTE,PAS IMPLMENTE Adds the specified cookie to the response. |
protected void |
connectionCloseEnabled(boolean bool)
Indique si l'on veut une connexion persistante ou non. |
boolean |
containsHeader(java.lang.String name)
Checks whether the response message header has a field with the specified name. |
java.lang.String |
encodeRedirectUrl(java.lang.String url)
Deprecated. Use encodeRedirectURL(String url) |
java.lang.String |
encodeRedirectURL(java.lang.String url)
PAS IMPLEMENTE ,PAS IMPLEMENTE,PAS IMPLMENTE Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed,
returns the URL unchanged. |
java.lang.String |
encodeUrl(java.lang.String url)
Deprecated. Use encodeURL(String url) |
java.lang.String |
encodeURL(java.lang.String url)
PAS IMPLEMENTE, PAS IMPLEMENTE, PAS IMPLMENTE Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. |
static java.lang.String |
findStatusString(int sc)
Methode provenant de JServ !! |
java.lang.String |
getCharacterEncoding()
Returns the name of the character set encoding used for the MIME body sent by this response. |
javax.servlet.ServletOutputStream |
getOutputStream()
Returns a ServletOutputStream suitable for writing binary
data in the response. |
java.io.PrintWriter |
getWriter()
Returns a PrintWriter object that you
can use to send character text to the client.
|
static java.lang.String |
parseCharacterEncoding(java.lang.String contentType)
Methode provenant de Jserv Parse a content-type header for the character encoding. |
protected void |
requestEnabled(boolean bool)
Indique si l'on veut juste envoyée une réponse http du type HTTP/1.1 200 OK etc... ou alors envoyer une requête
du type GET /hello.html HTTP/1.1 .
|
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)
PAS IMPLEMENTE, PAS IMPLEMENTE, PAS IMPLEMENTE Sends an error response to the client using the specified status code and descriptive message. |
void |
sendHttpHeaders()
Envoie l'entête d'une réponse HTTP ou d'une requêtte HTTP Choix en fonction de la methode requestEnabled()
Par défaut c'est uen réponse conforme au protocol HTTP. |
void |
sendRedirect(java.lang.String location)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
setContentLength(int len)
Sets the length of the content the server returns to the client. |
void |
setContentType(java.lang.String type)
Sets the content type of the response the server sends to the client. |
void |
setDateHeader(java.lang.String name,
long date)
Adds a field to the response header with the given name and date-valued field. |
protected void |
setGetMethod(java.lang.String path)
Si l'on appelle la méthode requestEnabled<\code> avec comme paramètre
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Adds a field to the response header with the given name and value. |
void |
setIntHeader(java.lang.String name,
int value)
Adds a field to the response header with the given name and integer value. |
protected void |
setPostMethod(java.lang.String path)
|
protected void |
setServer(java.lang.String Server)
Indique le nom du server à partir duquel on effectue la requête. |
void |
setStatus(int sc)
Sets the status code for this response. |
void |
setStatus(int sc,
java.lang.String sm)
Deprecated. ambiguous meaning. To send an error with a description page, use sendError(int sc, String msg); |
java.lang.String |
writeHttpHeaders()
Idem que sendHttpHeaders() mais l'entête est écrit dans un StringBuffer Pour pouvoir tester ou débugger |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
MyHttpServletResponse
public MyHttpServletResponse(java.io.OutputStream out)
Method Detail |
connectionCloseEnabled
protected void connectionCloseEnabled(boolean bool)
- Indique si l'on veut une connexion persistante ou non.
- Parameters:
bool
- si true alors la valeur de Connection est "close" sinon sa valeur est Keep-Alive
setServer
protected void setServer(java.lang.String Server)
- Indique le nom du server à partir duquel on effectue la requête.
requestEnabled
protected void requestEnabled(boolean bool)
- Indique si l'on veut juste envoyée une réponse http du type
HTTP/1.1 200 OK
etc... ou alors envoyer une requête du typeGET /hello.html HTTP/1.1
.C'est un détournement de l'utilisation de
MyHttpServletResponse
pour permetre de faire des requêtes...
setGetMethod
protected void setGetMethod(java.lang.String path)
- Si l'on appelle la méthode
requestEnabled<\code> avec comme paramètre
true<\code> alors on dait préciser le type de méthode que l'on veut effectuer. Ici, On veut effectuer un Get.
setPostMethod
protected void setPostMethod(java.lang.String path)
sendHttpHeaders
public void sendHttpHeaders()
- Envoie l'entête d'une réponse HTTP ou d'une requêtte HTTP
Choix en fonction de la methode
requestEnabled()
Par défaut c'est uen réponse conforme au protocol HTTP.
writeHttpHeaders
public java.lang.String writeHttpHeaders()
- Idem que sendHttpHeaders() mais l'entête est écrit dans un StringBuffer
Pour pouvoir tester ou débugger
- Returns:
- String l'entête http que l'on s'apprête à écrire dans le flux
addCookie
public void addCookie(javax.servlet.http.Cookie cookie)
- PAS IMPLEMENTE ,PAS IMPLEMENTE,PAS IMPLMENTE
Adds the specified cookie to the response. It can be called
multiple times to set more than one cookie.
- Specified by:
- addCookie in interface javax.servlet.http.HttpServletResponse
- Parameters:
cookie
- the Cookie to return to the client
containsHeader
public boolean containsHeader(java.lang.String name)
- Checks whether the response message header has a field with
the specified name.
- Specified by:
- containsHeader in interface javax.servlet.http.HttpServletResponse
- Parameters:
name
- the header field name- Returns:
- true if the response message header has a field with the specified name; false otherwise
encodeURL
public java.lang.String encodeURL(java.lang.String url)
- PAS IMPLEMENTE, PAS IMPLEMENTE, PAS IMPLMENTE
Encodes the specified URL by including the session ID in it,
or, if encoding is not needed, returns the URL unchanged.
The implementation of this method should include the logic to
determine whether the session ID needs to be encoded in the URL.
For example, if the browser supports cookies, or session
tracking is turned off, URL encoding is unnecessary.
All URLs emitted by a Servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
- Specified by:
- encodeURL in interface javax.servlet.http.HttpServletResponse
- Parameters:
url
- the url to be encoded.- Returns:
- the encoded URL if encoding is needed; the unchanged URL otherwise.
encodeRedirectURL
public java.lang.String encodeRedirectURL(java.lang.String url)
- PAS IMPLEMENTE ,PAS IMPLEMENTE,PAS IMPLMENTE
Encodes the specified URL for use in the
sendRedirect
method or, if encoding is not needed, returns the URL unchanged. The implementation of this method should include the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination differ from those used to decide whether to encode a normal link, this method is seperate from theencodeUrl
method.All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting canont be used with browsers which do not support cookies.
After this method is called, the response should be considered to be committed and should not be written to.
- Specified by:
- encodeRedirectURL in interface javax.servlet.http.HttpServletResponse
- Parameters:
url
- the url to be encoded.- Returns:
- the encoded URL if encoding is needed; the unchanged URL otherwise.
- See Also:
sendRedirect(java.lang.String)
,encodeUrl(java.lang.String)
encodeUrl
public java.lang.String encodeUrl(java.lang.String url)
- Deprecated. Use encodeURL(String url)
- PAS IMPLEMENTE ,PAS IMPLEMENTE,PAS IMPLMENTE Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method should include the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.
All URLs emitted by a Servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
- Specified by:
- encodeUrl in interface javax.servlet.http.HttpServletResponse
- Parameters:
url
- the url to be encoded.- Returns:
- the encoded URL if encoding is needed; the unchanged URL otherwise.
- PAS IMPLEMENTE ,PAS IMPLEMENTE,PAS IMPLMENTE Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method should include the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.
encodeRedirectUrl
public java.lang.String encodeRedirectUrl(java.lang.String url)
- Deprecated. Use encodeRedirectURL(String url)
- PAS IMPLEMENTE, PAS IMPLEMENTE, PAS IMPLEMENTE Encodes the specified URL for use in the
sendRedirect
method or, if encoding is not needed, returns the URL unchanged. The implementation of this method should include the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination differ from those used to decide whether to encode a normal link, this method is seperate from theencodeUrl
method.All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting canont be used with browsers which do not support cookies.
- Specified by:
- encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse
- Parameters:
url
- the url to be encoded.- Returns:
- the encoded URL if encoding is needed; the unchanged URL otherwise.
- PAS IMPLEMENTE, PAS IMPLEMENTE, PAS IMPLEMENTE Encodes the specified URL for use in the
sendError
public void sendError(int sc, java.lang.String msg) throws java.io.IOException
- PAS IMPLEMENTE, PAS IMPLEMENTE, PAS IMPLEMENTE
Sends an error response to the client using the specified status
code and descriptive message. If setStatus has previously been
called, it is reset to the error status code. The message is
sent as the body of an HTML page, which is returned to the user
to describe the problem. The page is sent with a default HTML
header; the message is enclosed in simple body tags
(<body></body>).
After using this method, the response should be considered to be committed and should not be written to.
- Specified by:
- sendError in interface javax.servlet.http.HttpServletResponse
- Parameters:
sc
- the status codemsg
- the detail message- Throws:
- java.io.IOException - If an I/O error has occurred.
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 occurred.
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. The URL must be absolute (for
example,
https://hostname/path/file.html
). Relative URLs are not permitted here.- 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 occurred.
setDateHeader
public void setDateHeader(java.lang.String name, long date)
- Adds a field to the response header with the given name and
date-valued field. The date is specified in terms of
milliseconds since the epoch. If the date field had 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 fieldvalue
- the header field's date value- See Also:
containsHeader(java.lang.String)
setHeader
public void setHeader(java.lang.String name, java.lang.String value)
- Adds a field to the response header with the given name and value.
If the field had 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 fieldvalue
- the header field's value- See Also:
containsHeader(java.lang.String)
setIntHeader
public void setIntHeader(java.lang.String name, int value)
- Adds a field to the response header with the given name and
integer value. If the field had 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 fieldvalue
- the header field's integer value- See Also:
containsHeader(java.lang.String)
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,
for the status codes 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- See Also:
sendError(int, java.lang.String)
setStatus
public void setStatus(int sc, java.lang.String sm)
- Deprecated. ambiguous meaning. To send an error with a description
page, use sendError(int sc, String msg);
- Sets the status code and message for this response. If the field had already been set, the new value overwrites the previous one. The message is sent as the body of an HTML page, which is returned to the user to describe the problem. The page is sent with a default HTML header; the message is enclosed in simple body tags (<body></body>).
- Specified by:
- setStatus in interface javax.servlet.http.HttpServletResponse
- Parameters:
sc
- the status codesm
- the status message
- Sets the status code and message for this response. If the field had already been set, the new value overwrites the previous one. The message is sent as the body of an HTML page, which is returned to the user to describe the problem. The page is sent with a default HTML header; the message is enclosed in simple body tags (<body></body>).
getCharacterEncoding
public java.lang.String getCharacterEncoding()
- Returns the name of the character set encoding used for
the MIME body sent by this response.
The character encoding is either the one specified in the content itself or another one the client understands. If no character encoding has been assigned, it is implicitly set to text/plain.
See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt) for more information about character encoding and MIME.
- Returns:
- a
String
specifying the name of the character set encoding, for example, text/plain
getOutputStream
public javax.servlet.ServletOutputStream getOutputStream() throws java.io.IOException
- Returns a
ServletOutputStream
suitable for writing binary data in the response. The servlet engine does not encode the binary data.- Returns:
- a
ServletOutputStream
for writing binary data - Throws:
- IllegalStateException - if you have already called the
getWriter
method for the same response- java.io.IOException - if an input or output exception occurred
- See Also:
getWriter()
getWriter
public java.io.PrintWriter getWriter() throws java.io.IOException
- Returns a
PrintWriter
object that you can use to send character text to the client. The character encoding used is the one specified in thecharset=
property of thesetContentType(java.lang.String)
method, which you must call before you call this method.If necessary, the MIME type of the response is modified to reflect the character encoding used.
You cannot use this method if you have already called
getOutputStream()
for thisServletResponse
object.- Returns:
- a
PrintWriter
object that can return text to the client - Throws:
- java.io.UnsupportedEncodingException - if the character encoding specified in
setContentType
cannot be used- IllegalStateException - if the
getOutputStream
method has already been called for this response object; in that case, you can't use this method- java.io.IOException - if an input or output exception occurred
- IllegalStateException - if the
- See Also:
getOutputStream()
,setContentType(java.lang.String)
setContentLength
public void setContentLength(int len)
- Sets the length of the content the server returns
to the client. In HTTP servlets, this method sets the
HTTP Content-Length header.
- Parameters:
len
- an integer specifying the length of the content being returned to the client; sets the Content-Length header
setContentType
public void setContentType(java.lang.String type)
- Sets the content type of the response the server sends to
the client. The content type may include the type of character
encoding used, for example,
text/html; charset=ISO-8859-4
.You can only use this method once, and you should call it before you obtain a
PrintWriter
orServletOutputStream
object to return a response.- Parameters:
type
- aString
specifying the MIME type of the content- See Also:
getOutputStream()
,getWriter()
findStatusString
public static final java.lang.String findStatusString(int sc)
- Methode provenant de JServ !!
Finds a status string from one of the standard
status code.
- Parameters:
sc
- The status code to find a descriptive string.- Returns:
- A string describing this status code.
parseCharacterEncoding
public static java.lang.String parseCharacterEncoding(java.lang.String contentType)
- Methode provenant de Jserv
Parse a content-type header for the character encoding. If the
content-type is null or there is no explicit character encoding,
ISO-8859-1 is returned.
- Parameters:
contentType
- a content type header.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |