xecure.servlet
Class XecureHttpServletResponse

java.lang.Object
  extended byxecure.servlet.XecureHttpServletResponse
All Implemented Interfaces:
javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse

public class XecureHttpServletResponse
extends java.lang.Object
implements javax.servlet.http.HttpServletResponse

XecureHttpServletResponse Ŭ·¡½º.
HttpServletResponse ÀÎÅÍÆäÀ̽º¸¦ ±¸ÇöÇÑ Å¬·¡½º·Î¼­ ¼­¹öÀÇ response ¸¦ ¾Ïȣȭ Çϴµ¥ »ç¿ëµÈ´Ù. doGet, doPost ÇÔ¼ö¿¡ Àü´ÞµÈ´Ù.


Field Summary
 javax.servlet.http.HttpServletResponse res
          ¼­ºí¸´ ¿£ÁøÀ¸·Î ºÎÅÍ Àü´ÞµÈ HttpServletResponse °´Ã¼ÀÌ´Ù.
 
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
XecureHttpServletResponse(XecureSession xecureSession, javax.servlet.http.HttpServletResponse res)
          XecureHttpServletResponse Constructor XecureHttpServlet À̳ª XecureHttpJspPage Ŭ·¡½º¿¡¼­ È£ÃâµÈ´Ù.
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds the specified cookie to the response.
 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)
          Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.
 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)
           
 java.lang.String getCharacterEncoding()
          Returns the character set encoding used for this MIME body.
 javax.servlet.ServletOutputStream getOutputStream()
          Response ÀÇ OutputStream °´Ã¼¸¦ ¸®ÅÏÇÑ´Ù.
 java.io.PrintWriter getWriter()
          Response ÀÇ Writer °´Ã¼¸¦ ¸®ÅÏÇÑ´Ù.
 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 setContentLength(int len)
          Sets the content length for this response.
 void setContentType(java.lang.String type)
          Sets the content type for this response.
 void setDateHeader(java.lang.String name, long date)
          Adds a field to the response header with the given name and date-valued field.
 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.
 void setStatus(int sc)
          Sets the status code for this response.
 void setStatus(int sc, java.lang.String sm)
          Sets the status code and message for this response.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

res

public javax.servlet.http.HttpServletResponse res
¼­ºí¸´ ¿£ÁøÀ¸·Î ºÎÅÍ Àü´ÞµÈ HttpServletResponse °´Ã¼ÀÌ´Ù.

Constructor Detail

XecureHttpServletResponse

public XecureHttpServletResponse(XecureSession xecureSession,
                                 javax.servlet.http.HttpServletResponse res)
XecureHttpServletResponse Constructor XecureHttpServlet À̳ª XecureHttpJspPage Ŭ·¡½º¿¡¼­ È£ÃâµÈ´Ù.

Parameters:
xecureSession - XecureSession ¾ÏÈ£ / ÀÎÁõ Á¤º¸ object
res - ¼­ºí¸´ ¿£ÁøÀ¸·Î ºÎÅÍ Àü´ÞµÈ HttpServletResponse °´Ã¼
Method Detail

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Response ÀÇ Writer °´Ã¼¸¦ ¸®ÅÏÇÑ´Ù. ¿©±â¿¡¼­´Â XecurePrintWriter °´Ã¼¸¦ »ý¼ºÇÏ°í ¸®ÅÏÇÑ´Ù.

Specified by:
getWriter in interface javax.servlet.ServletResponse
Throws:
java.io.IOException - if an I/O exception has occurred

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws java.io.IOException
Response ÀÇ OutputStream °´Ã¼¸¦ ¸®ÅÏÇÑ´Ù. ¿©±â¿¡¼­´Â XecureOutputStream °´Ã¼¸¦ »ý¼ºÇÏ°í ¸®ÅÏÇÑ´Ù.

Specified by:
getOutputStream in interface javax.servlet.ServletResponse
Throws:
java.io.IOException - if an I/O exception has occurred

setContentLength

public void setContentLength(int len)
Sets the content length for this response.

Specified by:
setContentLength in interface javax.servlet.ServletResponse
Parameters:
len - the content length

setContentType

public void setContentType(java.lang.String type)
Sets the content type for this response. This type may later be implicitly modified by addition of properties such as the MIME charset=<value> if the service finds it necessary, and the appropriate media type property has not been set.

This response property may only be assigned one time. If a writer is to be used to write a text response, this method must be called before the method getWriter. If an output stream will be used to write a response, this method must be called before the output stream is used to write response data.

Specified by:
setContentType in interface javax.servlet.ServletResponse
Parameters:
type - the content's MIME type
See Also:
getOutputStream, getWriter

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Returns the character set encoding used for this MIME body. The character encoding is either the one specified in the assigned content type, or one which the client understands. If no content type has yet been assigned, it is implicitly set to text/plain

Specified by:
getCharacterEncoding in interface javax.servlet.ServletResponse

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
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

setStatus

public void setStatus(int sc,
                      java.lang.String sm)
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 code
sm - the status message

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)

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 field
value - 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 field
value - the header field's integer value
See Also:
containsHeader(java.lang.String)

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 field
See Also:
containsHeader(java.lang.String)

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. 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>).

Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
Parameters:
sc - the status code
msg - 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.

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. 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)
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 the encodeUrl 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.
See Also:
sendRedirect(java.lang.String), encodeUrl(java.lang.String)

encodeURL

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

encodeRedirectURL

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