SimpleServlets v5.5.0

com.simpleservlets.pageprocessor
Class PageContext

java.lang.Object
  extended by com.simpleservlets.pageprocessor.PageContext

public class PageContext
extends Object

Encapsulates the context for this page request/response cycle. There are multiple public member variables which can be directly accessed (they are also declared final). There are also many convenience methods for accessing common information.

Author:
Paul Hyde

Field Summary
 ValueMap param
          The ValueMap for the "request parameters".
 PageProcessor processor
          The PageProcessor that created this PageContext to handle an incoming request.
 HttpServletRequest request
          The raw request that came in.
 String requestedPage
          The name of the page that was requested.
 HttpServletResponse response
          The raw response for this request/response cycle.
 Session session
          The PageProcessor user Session that is associated with the current request.
 ValueMap ss
          The ValueMap for the "session store".
 
Constructor Summary
PageContext(HttpServletRequest request, HttpServletResponse response, Session session, String requestedPage, PageProcessor processor)
          Used primarily by PageProcessor to create a context to pass when each request comes in.
 
Method Summary
 ValueMap getCookieMap()
          Returns a ValueMap with keys being the cookies' names and values being the cookies.
 ValueMap getCookieValueMap()
          Returns a ValueMap with keys being the cookies' names and values being the cookies' values (using getValue() on each cookie).
 String getPageURI(PageHandler handler)
          Returns a URI which includes the session/sequence information and the page name for the specified handler.
 String getPageURI(PageHandler handler, ParameterList paramList)
          Returns a URI which includes the session/sequence information and the page name for the specified handler and the specified parameters.
 String getPageURI(PageHandler handler, String paramKey, int paramValue)
          Returns a URI which includes the session/sequence information and the page name for the specified handler and the specified single parameter.
 String getPageURI(PageHandler handler, String paramKey, Object paramValue)
          Returns a URI which includes the session/sequence information and the page name for the specified handler and the specified single parameter.
 String getPageURI(PageHandler handler, String paramKey, String paramValue)
          Returns a URI which includes the session/sequence information and the page name for the specified handler and the specified single parameter.
 String getPageURI(String pageName)
          Returns a URI which includes the session/sequence information and the specified page name.
 String getPageURI(String pageName, ParameterList paramList)
          Returns a URI which includes the session/sequence information and the specified page name and the specified parameters.
 String getPageURI(String pageName, String paramKey, int paramValue)
          Returns a URI which includes the session/sequence information and the specified page name and the specified single parameter.
 String getPageURI(String pageName, String paramKey, Object paramValue)
          Returns a URI which includes the session/sequence information and the specified page name and the specified single parameter.
 String getPageURI(String pageName, String paramKey, String paramValue)
          Returns a URI which includes the session/sequence information and the specified page name and the specified single parameter.
 Value getParameter(String parameterName)
           
 ValueMap getParameterMap()
           
 ServletConfig getServletConfig()
           
 ServletContext getServletContext()
           
 ValueMap getSessionStore()
          Returns the session-specific storage map from the session.
 Value getSessionValue(String sessionStoreKey)
          Returns the Value stored in the Session for the required key specified.
 Exception getUncaughtException()
          Returns the exception stored for this request/response cycle (if any).
 String getWebAppURI()
          Returns the base URI for the whole web application (the root of the WAR-file).
 boolean isReload()
          Shortcut for isReload() on Session.
 void log(String message)
          Logs to the servlet container's log file.
 void log(String message, Throwable t)
          Logs to the servlet container's log file.
 void setUncaughtException(Exception uncaughtException)
          Specifies an exception that has not been caught.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

public final Session session
The PageProcessor user Session that is associated with the current request.


ss

public final ValueMap ss
The ValueMap for the "session store". Shortcut for getSessionStore() on Session.


param

public final ValueMap param
The ValueMap for the "request parameters". Shortcut for getParameterMap().


requestedPage

public final String requestedPage
The name of the page that was requested.


processor

public final PageProcessor processor
The PageProcessor that created this PageContext to handle an incoming request.


request

public final HttpServletRequest request
The raw request that came in.


response

public final HttpServletResponse response
The raw response for this request/response cycle.

Constructor Detail

PageContext

public PageContext(HttpServletRequest request,
                   HttpServletResponse response,
                   Session session,
                   String requestedPage,
                   PageProcessor processor)
Used primarily by PageProcessor to create a context to pass when each request comes in.

Method Detail

getParameterMap

public ValueMap getParameterMap()

getParameter

public Value getParameter(String parameterName)

getCookieMap

public ValueMap getCookieMap()
Returns a ValueMap with keys being the cookies' names and values being the cookies. Use this method if you need access to more information on the cookie beyond just the cookie's name and value (from getValue() on Cookie). If you are only concerned with a cookie's value, then getCookieValueMap() is likely to be more convenient.

See Also:
getCookieValueMap()

getCookieValueMap

public ValueMap getCookieValueMap()
Returns a ValueMap with keys being the cookies' names and values being the cookies' values (using getValue() on each cookie). Use this method if you need access to just the value information on the cookie. If you are concerned with more than a cookie's value, then getCookieMap() is likely to be more convenient.

See Also:
getCookieMap()

isReload

public boolean isReload()
Shortcut for isReload() on Session.


getPageURI

public String getPageURI(String pageName)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the specified page name. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse.

Throws:
PageProcessorException - if no page can be found with the specified name.

getPageURI

public String getPageURI(String pageName,
                         ParameterList paramList)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the specified page name and the specified parameters. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse.

Throws:
PageProcessorException - if no page can be found with the specified name.

getPageURI

public String getPageURI(String pageName,
                         String paramKey,
                         String paramValue)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the specified page name and the specified single parameter. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse.

Throws:
PageProcessorException - if no page can be found with the specified name.

getPageURI

public String getPageURI(String pageName,
                         String paramKey,
                         int paramValue)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the specified page name and the specified single parameter. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse.

Throws:
PageProcessorException - if no page can be found with the specified name.

getPageURI

public String getPageURI(String pageName,
                         String paramKey,
                         Object paramValue)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the specified page name and the specified single parameter. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse.

Throws:
PageProcessorException - if no page can be found with the specified name.

getPageURI

public String getPageURI(PageHandler handler)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the page name for the specified handler. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse. Equivalent to:
 return getPageURI(processor.getPageName(handler));
 

Throws:
PageProcessorException - if there are problems finding the name for the specified handler.

getPageURI

public String getPageURI(PageHandler handler,
                         ParameterList paramList)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the page name for the specified handler and the specified parameters. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse. Equivalent to:
 return getPageURI(processor.getPageName(handler), paramList);
 

Throws:
PageProcessorException - if there are problems finding the name for the specified handler.

getPageURI

public String getPageURI(PageHandler handler,
                         String paramKey,
                         String paramValue)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the page name for the specified handler and the specified single parameter. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse. Equivalent to:
 return getPageURI(processor.getPageName(handler), paramKey, paramValue);
 

Throws:
PageProcessorException - if there are problems finding the name for the specified handler.

getPageURI

public String getPageURI(PageHandler handler,
                         String paramKey,
                         int paramValue)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the page name for the specified handler and the specified single parameter. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse. Equivalent to:
 return getPageURI(processor.getPageName(handler), paramKey, paramValue);
 

Throws:
PageProcessorException - if there are problems finding the name for the specified handler.

getPageURI

public String getPageURI(PageHandler handler,
                         String paramKey,
                         Object paramValue)
                  throws PageProcessorException
Returns a URI which includes the session/sequence information and the page name for the specified handler and the specified single parameter. No need to use getRequestURI() on HttpServletRequest or encodeURL() on HttpServletResponse. Equivalent to:
 return getPageURI(processor.getPageName(handler), paramKey, paramValue);
 

Throws:
PageProcessorException - if there are problems finding the name for the specified handler.

getWebAppURI

public String getWebAppURI()
Returns the base URI for the whole web application (the root of the WAR-file).


getUncaughtException

public Exception getUncaughtException()
Returns the exception stored for this request/response cycle (if any). Returns null if there is no exception.


setUncaughtException

public void setUncaughtException(Exception uncaughtException)
Specifies an exception that has not been caught.


log

public void log(String message,
                Throwable t)
Logs to the servlet container's log file.


log

public void log(String message)
Logs to the servlet container's log file.


getServletContext

public ServletContext getServletContext()

getServletConfig

public ServletConfig getServletConfig()

getSessionStore

public ValueMap getSessionStore()
Returns the session-specific storage map from the session.


getSessionValue

public Value getSessionValue(String sessionStoreKey)
                      throws ValueMapRequiredKeyException
Returns the Value stored in the Session for the required key specified.

Throws:
ValueMapRequiredKeyException

SimpleServlets v5.5.0

Copyright © 2001-2007 Programix Incorporated. All rights reserved. SimpleServlets is free and is OSI Certified Open Source Software under the BSD license.