org.webmacro.servlet
Class WebContext

java.lang.Object
  extended byorg.webmacro.Context
      extended byorg.webmacro.servlet.WebContext
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map

public class WebContext
extends Context

This is an implementation of the WebContext interface. It has the ability to hook in commonly re-usable utilities via the configuraiton file for the Broker. These commonly re-usable utilities are then made available for use in the context. They include: Cookie, Form, FormList, and several others--see the WebMacro.properties file for the actual list, and a description of what's been loaded.

This class is made to be prototyped. You create a prototypical instance of the WebContext containing all the desired tools and a broker. You then use the newInstance(req,resp) method to create an instance of the WebContext to use versus a particular request.

IMPLEMENTATION NOTE: If you subclass this method you must provide a sensible implementation of the clone() method. This class uses clone() to create instances of the prototype in the newInstance method. You should also be sure and implement the clear() method as well.


Nested Class Summary
 
Nested classes inherited from class org.webmacro.Context
Context.TemplateEvaluationContext
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
WebContext(Broker broker, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Construct a new WebContext.
 
Method Summary
 void clear()
          Clear a WebContext of it's non-shared data
 CGI_Impersonator getCGI()
          Get the CGI Tool
 javax.servlet.http.Cookie getCookie(java.lang.String name)
          get a cookie from the request
 java.lang.String getForm(java.lang.String field)
          Get the value of a form variable from the request
 java.lang.String[] getFormList(java.lang.String field)
          Get the value of a form variable from the request as an array
 java.lang.Object getPossibleForm(java.lang.String strKey)
          Try to get the value of a form variable from the request
 javax.servlet.http.HttpServletRequest getRequest()
          The HttpServletRequest object which contains information provided by the HttpServlet superclass about the Request.
 javax.servlet.http.HttpServletResponse getResponse()
          The HttpServletResponse object which contains information about the response we are going to send back.
 javax.servlet.http.HttpSession getSession()
          get the session object
 void setCookie(java.lang.String name, java.lang.String value)
          send a cookie in the response
 
Methods inherited from class org.webmacro.Context
clone, cloneContext, containsKey, containsValue, entrySet, get, getBroker, getCurrentLocation, getEvaluationExceptionHandler, getLog, getLog, getMap, getProperty, getProperty, getTemplateEvaluationContext, internalGet, internalGet, isEmpty, keySet, put, put, put, put, put, put, put, put, put, put, putAll, putFunction, putGlobalFunction, remove, set, setEvaluationExceptionHandler, setMap, setProperty, setProperty, size, toString, values
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

WebContext

public WebContext(Broker broker,
                  javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp)
Construct a new WebContext. The WebContext will have WebContextTools in addition to the ordinary ContextTools loaded from config.

Method Detail

clear

public void clear()
Clear a WebContext of it's non-shared data

Specified by:
clear in interface java.util.Map
Overrides:
clear in class Context

getRequest

public final javax.servlet.http.HttpServletRequest getRequest()
The HttpServletRequest object which contains information provided by the HttpServlet superclass about the Request. Much of this data is provided in other forms later on; those interfaces get their data from this object. In particular the form data has already been parsed.

See Also:
HttpServletRequest

getResponse

public final javax.servlet.http.HttpServletResponse getResponse()
The HttpServletResponse object which contains information about the response we are going to send back. Many of these services are provided through other interfaces here as well; they are built on top of this object.

See Also:
HttpServletResponse

getPossibleForm

public final java.lang.Object getPossibleForm(java.lang.String strKey)
Try to get the value of a form variable from the request


getForm

public final java.lang.String getForm(java.lang.String field)
Get the value of a form variable from the request


getFormList

public final java.lang.String[] getFormList(java.lang.String field)
Get the value of a form variable from the request as an array


getCGI

public final CGI_Impersonator getCGI()
Get the CGI Tool


getCookie

public final javax.servlet.http.Cookie getCookie(java.lang.String name)
get a cookie from the request


setCookie

public final void setCookie(java.lang.String name,
                            java.lang.String value)
send a cookie in the response


getSession

public final javax.servlet.http.HttpSession getSession()
get the session object



Copyright © 1999-2006 WebMacro. All Rights Reserved.