jrun.servlet
Class JRunResponse

jrun.servlet.JRunResponse
All Implemented Interfaces:
HttpConstants

public final class JRunResponse
implements HttpConstants

Implementation of HttpServletResponse. This is the main workhorse of response. It coordinates buffering, and whether or not headers are committed. Much of the ServletResponse functionality is deferred to the underlying response object from the actual connection.


Fields inherited from interface jrun.servlet.HttpConstants
ACCEPT_CHARSET, ACCEPT_LANGUAGE, CACHE_CONTROL, CONNECTION, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_TYPE, COOKIE, DATE, EXPIRES, HOST, LOCATION, SERVER, SET_COOKIE
 
Method Summary
 void closeFinal()
          called by the servlet engine after a servlet finishes running.
 java.lang.String encodeRedirectUrl(java.lang.String u)
           
 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 encodeUrl(java.lang.String u)
           
 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.
 void flushBuffer()
          flush the underlying response without knowing ahead of time which output method was called.
 java.lang.String getCharacterEncoding()
          Returns the character set encoding used for this MIME body.
 java.lang.String getContentType()
          Get the content type.
 java.util.Locale getLocale()
          Gets the locale for this response.
 javax.servlet.ServletOutputStream getOutputStream()
          Returns an output stream for writing binary response data.
 java.io.PrintWriter getWriter()
          Returns a print writer for writing formatted text responses.
 void reset()
          Resets the response by clearing the headers and output stream.
 void resetBuffer()
          reset any output that has been generated, but don't reset headers, status code, or cookies.
 void sendError(int s)
           
 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 setContentType(java.lang.String type)
          Sets the content type for this response.
 void setLocale(java.util.Locale locale)
          Sets the locale for this response.
 

Method Detail

resetBuffer

public final void resetBuffer()
reset any output that has been generated, but don't reset headers, status code, or cookies. Used when forwarding, and in sendError and sendRedirect.

reset

public final void reset()
Resets the response by clearing the headers and output stream. Throws an IllegalStateException if the output stream has already been committed.

flushBuffer

public final void flushBuffer()
                       throws java.io.IOException
flush the underlying response without knowing ahead of time which output method was called.

getCharacterEncoding

public final java.lang.String getCharacterEncoding()
Returns the character set encoding used for this MIME body. of the servlet response
Returns:
an encoding. never returns null.

getOutputStream

public final javax.servlet.ServletOutputStream getOutputStream()
                                                        throws java.io.IOException
Returns an output stream for writing binary response data.

getWriter

public final java.io.PrintWriter getWriter()
                                    throws java.io.IOException
Returns a print writer for writing formatted text responses.

setContentType

public void setContentType(java.lang.String type)
Sets the content type for this response.

getContentType

public final java.lang.String getContentType()
Get the content type.

setLocale

public final void setLocale(java.util.Locale locale)
Sets the locale for this response.
Parameters:
locale - Locale object.

getLocale

public final java.util.Locale getLocale()
Gets the locale for this response. It returns system's default locale if setLocale() is not called.
Returns:
the response's locale object.

closeFinal

public final void closeFinal()
                      throws java.io.IOException
called by the servlet engine after a servlet finishes running. Just invoke close on the output stream or Writer, since that is how things really get closed. (That is how the Servlet author can do it, so we do it the same way) This method implements the Closure of Response object as specified in SRV.5.5 of the Servlet 2.3 spec. it is called after the servlet completes, after setContentLength() bytes have been sent, or after sendError() or sendRedirect(). After this closure has occurred, further output is ignored. at least that's what the spec says. Tomcat (and jrun) both throw IOExceptions if you try to write after the stream is closed. must be in cts.

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.

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 URL only gets encoded if there is a session, and either the session is new (so we don't know whether cookies are supported), or the requested session id did not come from a cookie (so we know cookies are not supported)

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.

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.

sendError

public void sendError(int s)
               throws java.io.IOException

encodeUrl

public java.lang.String encodeUrl(java.lang.String u)

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String u)


Copyright � 2002 Macromedia Corporation. All Rights Reserved.