org.locomotive.loco.servlet
Class LocoServletResponse

java.lang.Object
  |
  +--org.locomotive.loco.Response
        |
        +--org.locomotive.loco.servlet.LocoServletResponse
Direct Known Subclasses:
HTTPResponse

public class LocoServletResponse
extends Response
implements javax.servlet.ServletResponse, javax.servlet.http.HttpServletResponse

The response class for the servlet interface provides us all the methods required for both ServletResponses and HttpServletResponses. It uses the Response outputStream for its ServletOutputStream, and its own internal printwriter for the printWriter


Inner classes inherited from class org.locomotive.loco.Response
Response.ResponseOutputStream
 
Field Summary
protected  java.io.PrintWriter resw
           
protected  int status
           
protected  boolean used_os
           
protected  boolean used_writer
           
 
Fields inherited from class org.locomotive.loco.Response
char_encoding, content_type, header_was_flushed, os, reply_type, REPLY_TYPE_CGI, REPLY_TYPE_ISAPI, REPLY_TYPE_NSAPI, request_id, resos
 
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
LocoServletResponse(java.io.OutputStream os, int request_id, int reply_type)
           
 
Method Summary
protected  void addStatusToHeaders()
          we don't currently have access to the status line via our tunnels, so we really can't do anything here...
 java.lang.String encodeRedirectUrl(java.lang.String url)
          Deprecated. in favor of encodeRedirectURL
 java.lang.String encodeRedirectURL(java.lang.String url)
          Encodes a url for use by the sendRedirect method.
 java.lang.String encodeUrl(java.lang.String url)
          Deprecated. in favor of encodeURL
 java.lang.String encodeURL(java.lang.String url)
          Encodes a url with any information necessary for session persistence.
protected  Response generateInclude()
          Generates a crippled version of this response which will not allow headers to be set.
 javax.servlet.ServletOutputStream getOutputStream()
          Retrieve our friendly ServletOutputStream.
 java.io.PrintWriter getWriter()
          Retrieve the Response PrintWriter
 void sendError(int status_code)
          Sends an error back to the requestor with the specified status code.
 void sendError(int status_code, java.lang.String error_msg)
          Sends an error back to the requestor with the specified status code and error message.
 void sendRedirect(java.lang.String location)
          sends a redirect response to client.
 void setContentLength(int len)
          Here for the servlet implementation- don't like this, though.
 void setDateHeader(java.lang.String name, long date)
          Sets a response header with the specified name and date.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets a response header with the specified name and value.
 void setIntHeader(java.lang.String name, int value)
          Sets a response header with the specified name and integer value.
 void setStatus(int status_code)
          Deprecated. no no apparent reason...
 void setStatus(int status_code, java.lang.String message)
          Deprecated. for no apparent reason
 void writeHeader(Log server_log)
          makes sure the status makes it into the header
 
Methods inherited from class org.locomotive.loco.Response
addBytes, addCookie, addHTTPHeader, addString, clearBody, clearHeaders, containsHeader, flush, flush, getCharacterEncoding, getCurrentResponseLength, getHeaderCount, setAutoflush, setContentType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

used_writer

protected boolean used_writer

used_os

protected boolean used_os

status

protected int status

resw

protected java.io.PrintWriter resw
Constructor Detail

LocoServletResponse

public LocoServletResponse(java.io.OutputStream os,
                           int request_id,
                           int reply_type)
Method Detail

setContentLength

public void setContentLength(int len)
Here for the servlet implementation- don't like this, though. Doesn't necessarily reflect the size of the content
Specified by:
setContentLength in interface javax.servlet.ServletResponse

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws java.io.IOException
Retrieve our friendly ServletOutputStream.
Specified by:
getOutputStream in interface javax.servlet.ServletResponse

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Retrieve the Response PrintWriter
Specified by:
getWriter in interface javax.servlet.ServletResponse

encodeRedirectURL

public java.lang.String encodeRedirectURL(java.lang.String url)
Encodes a url for use by the sendRedirect method. As we do not currently keep any information in urls, we return the url unchanged.
Specified by:
encodeRedirectURL in interface javax.servlet.http.HttpServletResponse

encodeURL

public java.lang.String encodeURL(java.lang.String url)
Encodes a url with any information necessary for session persistence. As we do not currently keep any information in urls, we return the url unchanged.
Specified by:
encodeURL in interface javax.servlet.http.HttpServletResponse

sendError

public void sendError(int status_code)
               throws java.io.IOException
Sends an error back to the requestor with the specified status code. Status codes are defined in HttpServletResponse.
Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
See Also:
javax.http.HttpServletResponse

sendError

public void sendError(int status_code,
                      java.lang.String error_msg)
               throws java.io.IOException
Sends an error back to the requestor with the specified status code and error message. Status codes are defined in HttpServletResponse.
Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
See Also:
javax.http.HttpServletResponse

sendRedirect

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException
sends a redirect response to client. Location must be an absolute URL.
Specified by:
sendRedirect in interface javax.servlet.http.HttpServletResponse
Throws:
java.lang.IllegalArgumentException - if the redirect URL is not absolute

setDateHeader

public void setDateHeader(java.lang.String name,
                          long date)
Sets a response header with the specified name and date. The date should be specified as the number of seconds since Jan 1, 1970. Sets the date in the following format:
Sun, 06 Nov 1994 08:49:37 GMT  
 
Specified by:
setDateHeader in interface javax.servlet.http.HttpServletResponse

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
Sets a response header with the specified name and integer value.
Specified by:
setIntHeader in interface javax.servlet.http.HttpServletResponse

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Sets a response header with the specified name and value. This will overwrite a header with the same name, if it exists.
Specified by:
setHeader in interface javax.servlet.http.HttpServletResponse

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String url)
Deprecated. in favor of encodeRedirectURL

Encodes a url with any information necessary for session persistence. As we do not currently keep any information in urls, we return the url unchanged.
Specified by:
encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse

encodeUrl

public java.lang.String encodeUrl(java.lang.String url)
Deprecated. in favor of encodeURL

Encodes a url with any information necessary for session persistence. As we do not currently keep any information in urls, we return the url unchanged.
Specified by:
encodeUrl in interface javax.servlet.http.HttpServletResponse

setStatus

public void setStatus(int status_code)
Deprecated. no no apparent reason...

sets the status for this response and sends the response off.
Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse

setStatus

public void setStatus(int status_code,
                      java.lang.String message)
Deprecated. for no apparent reason

sets the status for this reponse, and sends the specified message as the body of the response.
Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse

writeHeader

public void writeHeader(Log server_log)
                 throws java.io.IOException
makes sure the status makes it into the header
Overrides:
writeHeader in class Response

addStatusToHeaders

protected void addStatusToHeaders()
we don't currently have access to the status line via our tunnels, so we really can't do anything here...

generateInclude

protected Response generateInclude()
                            throws java.io.IOException
Generates a crippled version of this response which will not allow headers to be set. It is used by the RequestDispatcher.include() method to provide a safe way to include content of other servlets without adversely affecting the state of the request. The headers are written before this object is created, so no headers can be created here. If errors are sent here, then the printStream will be closed, and any attempts byt the parent servlet to write responses will result in errors.