sunlabs.brazil.servlet
Class BServletRequest

java.lang.Object
  extended by sunlabs.brazil.server.Request
      extended by sunlabs.brazil.servlet.BServletRequest (view source)

public class BServletRequest
extends Request

This is a subclass of Request that is used by BrazilServlet to map servlet style requests and responses to and from Brazil style requests.

See Also:
BServletSocket, BServletServerSocket, BrazilServlet, Request

Nested Class Summary
static class BServletRequest.HttpOutputStream
          An HttpOutputStream that is used by the Brazil Servlet adaptor to add the web application context path to the front of all response URI's so subsequent requests will be mapped to the BrazilServlet's context.
 
Field Summary
 
Fields inherited from class sunlabs.brazil.server.Request
connectionHeader, headers, keepAlive, MAX_BLANKS, method, out, postData, props, protocol, query, responseHeaders, server, serverProps, serverProtocol, sock, startMillis, url, version
 
Method Summary
 boolean getRequest()
          Converts an HTTP request from the form encapsulated in a servlet request object to the form expected by Brazil handlers.
 void redirect(String url, String body)
          Responds to an HTTP request with a redirection reply, telling the client that the requested url has moved.
 String serverUrl()
          Returns the server's fully-qualified base URL.
 void setStatus(int code)
          Sets response code in the servlet response object.
 
Methods inherited from class sunlabs.brazil.server.Request
addHeader, addHeader, addSharedProps, getProtocol, getQueryData, getQueryData, getRequestHeader, getReuseCount, getSocket, getStatus, log, log, removeSharedProps, replaceHeader, sendError, sendError, sendHeaders, sendResponse, sendResponse, sendResponse, sendResponse, sendResponse, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getRequest

public boolean getRequest()
                   throws IOException
Converts an HTTP request from the form encapsulated in a servlet request object to the form expected by Brazil handlers.

Overrides:
getRequest in class Request
Returns:
true if the request was successfully read and parsed, false if the request was malformed.
Throws:
IOException - if there was an IOException reading from the socket. See the socket documentation for a description of socket exceptions.

setStatus

public void setStatus(int code)
Sets response code in the servlet response object.

Overrides:
setStatus in class Request
Parameters:
code - The HTTP status code, such as 200 or 404. If < 0, the HTTP status code will not be changed.
See Also:
Request.sendHeaders(int, String, int)

serverUrl

public String serverUrl()
Returns the server's fully-qualified base URL. This is "http://" followed by the server's hostname and port.

If the HTTP request header "Host" is present, it specifies the hostname and port that will be used instead of the server's internal name for itself. Due to bugs in certain browsers, when using the server's internal name, the port number will be elided if it is 80.

Overrides:
serverUrl in class Request
Returns:
The string representation of the server's URL.

redirect

public void redirect(String url,
                     String body)
              throws IOException
Description copied from class: Request
Responds to an HTTP request with a redirection reply, telling the client that the requested url has moved. Generally, this is used if the client did not put a '/' on the end of a directory.

Overrides:
redirect in class Request
Parameters:
url - The URL the client should have requested. This URL may be fully-qualified (in the form "http://....") or host-relative (in the form "/...").
body - The body of the redirect response, or null to send a hardcoded message.
Throws:
IOException

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.