    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.w3c.jigsaw.servlet.JigsawHttpServletResponse

    java.lang.Object
       |
       +----org.w3c.jigsaw.servlet.JigsawHttpServletResponse

public class JigsawHttpServletResponse
extends Object
implements HttpServletResponse

##

jrequest
REMOVE_HEADER

##

addCookie(Cookie)
  Adds the specified cookie to the response.
containsHeader(String)
  Checks whether the response message header has a field with the specified name.
convertCookie(Cookie)
encodeRedirectUrl(String)
  Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.
encodeUrl(String)
  Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
flushStream()
getCharacterEncoding()
  Return the Charset parameter of content type
getJigsawOutputStream()
getOutputStream()
  Returns an output stream for writing binary response data.
getWriter()
  Returns a print writer for writing formatted text responses.
sendError(int)
  Sends an error response to the client using the specified status code and a default message.
sendError(int, String)
  Sends an error response to the client using the specified status code and descriptive message.
sendRedirect(String)
  Sends a temporary redirect response to the client using the specified redirect location URL.
setContentLength(int)
  Sets the content length for this response.
setContentType(String)
  Sets the content type for this response.
setDateHeader(String, long)
  Adds a field to the response header with the given name and date-valued field.
setHeader(String, String)
  Adds a field to the response header with the given name and value.
setIntHeader(String, int)
  Adds a field to the response header with the given name and integer value.
setServletRequest(JigsawHttpServletRequest)
setStatus(int)
  Sets the status code for this response.
setStatus(int, String)
  Sets the status code and message for this response.
unsetHeader(String)

##

jrequest

     protected JigsawHttpServletRequest jrequest

REMOVE_HEADER

     public static final String REMOVE_HEADER

##

setServletRequest

     protected void setServletRequest(JigsawHttpServletRequest jrequest)

setContentLength

     public void setContentLength(int i)

  Sets the content length for this response.

  Parameters:
    len - - the content length

setContentType

     public void setContentType(String spec)

  Sets the content type for this response. This type may later be implicitly modified by addition of properties such as the MIME charset= 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.

  Parameters:
    spec - - the content's MIME type
  See Also:
    getOutputStream, getWriter

getOutputStream

     public synchronized ServletOutputStream getOutputStream() throws IOException

  Returns an output stream for writing binary response data.

  Returns:
    A ServletOutputStream
  Throws: IOException
    if an I/O exception has occurred
  Throws: IllegalStateException
    if getWriter has been called on this same request.
  See Also:
    getWriter

getJigsawOutputStream

     protected ServletOutputStream getJigsawOutputStream() throws IOException

setStatus

     public void setStatus(int i,
                           String reason)

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

  Parameters:
    i - - the status code
    reason - - the status message

setStatus

     public void setStatus(int i)

  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.

  Parameters:
    i - - the status code
  See Also:
    sendError

setHeader

     public void setHeader(String name,
                           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.

  Parameters:
    name - - the name of the header field
    value - - the header field's value
  See Also:
    containsHeader

setIntHeader

     public void setIntHeader(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.

  Parameters:
    name - - the name of the header field
    value - - the header field's integer value
  See Also:
    containsHeader

setDateHeader

     public void setDateHeader(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.

  Parameters:
    name - - the name of the header field
    value - - the header field's date value
  See Also:
    containsHeader

unsetHeader

     public void unsetHeader(String name)

sendError

     public void sendError(int i,
                           String msg) throws 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 (
  ).

  Parameters:
    sc - - the status code
    msg - - the detail message
  Throws: IOException
    If an I/O error has occurred.

sendError

     public void sendError(int i) throws IOException

  Sends an error response to the client using the specified status code and a default message.

  Parameters:
    sc - - the status code
  Throws: IOException
    If an I/O error has occurred.

sendRedirect

     public void sendRedirect(String url) throws 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.

  Parameters:
    url - - the redirect location URL
  Throws: IOException
    If an I/O error has occurred.

containsHeader

     public boolean containsHeader(String header)

  Checks whether the response message header has a field with the specified name.

  Parameters:
    name - - the header field name
  Returns:
    true if the response message header has a field with the specified name; false otherwise

addCookie

     public void addCookie(Cookie cookie)

  Adds the specified cookie to the response. It can be called multiple times to set more than one cookie.

  Parameters:
    cookie - - the Cookie to return to the client

convertCookie

     public HttpSetCookie convertCookie(Cookie cookie)

encodeRedirectUrl

     public String encodeRedirectUrl(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.

  Parameters:
    url - - the url to be encoded.
  Returns:
    the encoded URL if encoding is needed; the unchanged URL otherwise.
  See Also:
    sendRedirect, encodeUrl

encodeUrl

     public String encodeUrl(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.

  Parameters:
    url - - the url to be encoded.
  Returns:
    the encoded URL if encoding is needed; the unchanged URL otherwise.

getCharacterEncoding

     public String getCharacterEncoding()

  Return the Charset parameter of content type

  Returns:
    A String instance

getWriter

     public synchronized PrintWriter getWriter() throws IOException, UnsupportedEncodingException

  Returns a print writer for writing formatted text responses. The MIME type of the response will be modified, if necessary, to reflect the character encoding used, through the charset=... property. This means that the content type must be set before calling this method.

  Throws: UnsupportedEncodingException
    if no such encoding can be provided
  Throws: IllegalStateException
    if getOutputStream has been called on this same request.
  Throws: IOException
    on other errors.
  See Also:
    getOutputStream, setContentType

flushStream

     protected synchronized void flushStream()

    All Packages  Class Hierarchy  This Package  Previous  Next  Index