|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.primix.tapestry.RequestContext
This class encapsulates all the relevant data for one request cycle of an
ApplicationServlet
, that is:
It also provides methods for:
RequestContext
(for debugging).
This class is not a component, but does implement IRender
. When asked to render
(perhaps as the delegate of a Delegator
component}
it simply invokes write(IResponseWriter)
to display all debugging output.
This class is derived from the original class
com.primix.servlet.RequestContext
,
part of the ServletUtils framework available from
The Giant
Java Tree.
Constructor Summary | |
RequestContext(ApplicationServlet servlet,
HttpServletRequest request,
HttpServletResponse response)
Creates a RequestContext from its components. |
Method Summary | |
void |
addCookie(Cookie cookie)
Adds a Cookie to the response. |
void |
addCookie(java.lang.String name,
java.lang.String value)
Adds a simple Cookie . |
HttpSession |
createSession()
Like getSession() , but forces the creation of
the HttpSession , if necessary. |
static java.lang.String |
encodeColor(java.awt.Color color)
Encodes a java.awt.Color in the standard HTML
format: a pound sign ('#'), followed by six hex digits for
specifying the red, green and blue components of the color. |
void |
forward(java.lang.String path)
Forwards the request to a new resource, typically a JSP. |
java.lang.String |
getAbsoluteURL(java.lang.String URI)
Builds an absolute URL from the given URI, using the HttpServletRequest
as the source for scheme, server name and port. |
java.lang.String |
getAbsoluteURL(java.lang.String URI,
java.lang.String scheme,
java.lang.String server,
int port)
Does some easy checks to turn a path (or URI) into an absolute URL. |
Cookie |
getCookie(java.lang.String name)
Gets a named Cookie . |
java.lang.String |
getCookieValue(java.lang.String name)
Reads the named Cookie and returns its value (if it exists), or
null if it does not exist. |
java.lang.String |
getParameter(java.lang.String name)
Returns the named parameter from the HttpServletRequest . |
java.lang.String[] |
getParameterValues(java.lang.String name)
For parameters that are, or are possibly, multi-valued, this method returns all the values as an array of Strings. |
java.lang.String |
getPathInfo(int index)
Returns the pathInfo string at the given index. |
int |
getPathInfoCount()
Returns the number of items in the pathInfo. |
HttpServletRequest |
getRequest()
|
HttpServletResponse |
getResponse()
|
ApplicationServlet |
getServlet()
|
HttpSession |
getSession()
Returns the HttpSession , if necessary, invoking
HttpServletRequest.getSession(boolean) . |
void |
redirect(java.lang.String path)
Invokes HttpResponse.sendRedirect() , but
massages path , supplying missing elements to
make it a full URL (i.e., specifying scheme, server, port, etc.). |
void |
render(IResponseWriter writer,
IRequestCycle cycle)
Invokes write(IResponseWriter) , which is used for debugging. |
void |
write(IResponseWriter writer)
Writes the state of the context to the writer, typically for inclusion in a HTML page returned to the user. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RequestContext(ApplicationServlet servlet, HttpServletRequest request, HttpServletResponse response)
RequestContext
from its components.Method Detail |
public void addCookie(java.lang.String name, java.lang.String value)
Cookie
. To set a Cookie with attributes,
use addCookie(Cookie)
.public void addCookie(Cookie cookie)
Cookie
to the response. Once added, the
Cookie will also be available to getCookie(String)
method.
Cookies should only be added before invoking
ServletResponse.getWriter()
..
public static java.lang.String encodeColor(java.awt.Color color)
java.awt.Color
in the standard HTML
format: a pound sign ('#'), followed by six hex digits for
specifying the red, green and blue components of the color.public void forward(java.lang.String path) throws ServletException, java.io.IOException
public java.lang.String getAbsoluteURL(java.lang.String URI)
HttpServletRequest
as the source for scheme, server name and port.getAbsoluteURL(String, String, String, int)
public java.lang.String getAbsoluteURL(java.lang.String URI, java.lang.String scheme, java.lang.String server, int port)
public Cookie getCookie(java.lang.String name)
Cookie
.name
- The name of the Cookie
.Cookie
, or null if no Cookie with that
name exists.public java.lang.String getCookieValue(java.lang.String name)
Cookie
and returns its value (if it exists), or
null if it does not exist.public java.lang.String getParameter(java.lang.String name)
HttpServletRequest
.
Use getParameterValues(String)
for parameters that may
invlude multiple values.
public java.lang.String[] getParameterValues(java.lang.String name)
public java.lang.String getPathInfo(int index)
public int getPathInfoCount()
public HttpServletRequest getRequest()
public HttpServletResponse getResponse()
public ApplicationServlet getServlet()
public HttpSession getSession()
HttpSession
, if necessary, invoking
HttpServletRequest.getSession(boolean)
. However,
this method will not create a session.public HttpSession createSession()
getSession()
, but forces the creation of
the HttpSession
, if necessary.public void redirect(java.lang.String path) throws java.io.IOException
HttpResponse.sendRedirect()
, but
massages path
, supplying missing elements to
make it a full URL (i.e., specifying scheme, server, port, etc.).
The 2.2 Servlet API will do this automatically, and a little more, according to the early documentation.
public void write(IResponseWriter writer)
public void render(IResponseWriter writer, IRequestCycle cycle) throws RequestCycleException
write(IResponseWriter)
, which is used for debugging.render
in interface IRender
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |