|
|||||||||
| Home >> All >> org >> apache >> commons >> jxpath >> [ servlet overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.commons.jxpath.servlet
Class JXPathServletContexts

java.lang.Objectorg.apache.commons.jxpath.servlet.JXPathServletContexts
- public final class JXPathServletContexts
- extends java.lang.Object
Static methods that allocate and cache JXPathContexts bound to PageContext, ServletRequest, HttpSession and ServletContext.
The JXPathContext returned by getPageContext() 55 provides access to all scopes via the PageContext.findAttribute() method. Thus, an expression like "foo" will first look for the attribute named "foo" in the "page" context, then the "request" context, then the "session" one and finally in the "application" context.
If you need to limit the attibute lookup to just one scope, you can use the pre-definded variables "page", "request", "session" and "application". For example, the expression "$session/foo" extracts the value of the session attribute named "foo".
Following are some implementation details. There is a separate JXPathContext for each of the four scopes. These contexts are chained according to the nesting of the scopes. So, the parent of the "page" JXPathContext is a "request" JXPathContext, whose parent is a "session" JXPathContext (that is if there is a session), whose parent is an "application" context.
The XPath context node for each context is the corresponding object: PageContext, ServletRequest, HttpSession or ServletContext. This feature can be used by servlets. A servlet can use one of the methods declared by this class and work with a specific JXPathContext for any scope.
Since JXPath chains lookups for variables and extension functions, variables and extension function declared in the outer scopes are also available in the inner scopes.
Each of the four context declares exactly one variable, the value of which is the corresponding object: PageContext, etc.
The "session" variable will be undefined if there is no session for this servlet. JXPath does not automatically create sessions.
- Version:
- $Revision: 1.6 $ $Date: 2004/05/08 15:10:49 $
| Field Summary | |
private static org.apache.commons.jxpath.JXPathContextFactory |
factory
|
| Constructor Summary | |
JXPathServletContexts()
|
|
| Method Summary | |
static org.apache.commons.jxpath.JXPathContext |
getApplicationContext(javax.servlet.ServletContext servletContext)
Returns a JXPathContext bound to the "application" scope. |
static org.apache.commons.jxpath.JXPathContext |
getPageContext(javax.servlet.jsp.PageContext pageContext)
Returns a JXPathContext bound to the "page" scope. |
static org.apache.commons.jxpath.JXPathContext |
getRequestContext(javax.servlet.ServletRequest request,
javax.servlet.ServletContext servletContext)
Returns a JXPathContext bound to the "request" scope. |
static org.apache.commons.jxpath.JXPathContext |
getSessionContext(javax.servlet.http.HttpSession session,
javax.servlet.ServletContext servletContext)
Returns a JXPathContext bound to the "session" scope. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
factory
private static org.apache.commons.jxpath.JXPathContextFactory factory
| Constructor Detail |
JXPathServletContexts
public JXPathServletContexts()
| Method Detail |
getPageContext
public static org.apache.commons.jxpath.JXPathContext getPageContext(javax.servlet.jsp.PageContext pageContext)
- Returns a JXPathContext bound to the "page" scope. Caches that context
within the PageContext itself.
getRequestContext
public static org.apache.commons.jxpath.JXPathContext getRequestContext(javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)
- Returns a JXPathContext bound to the "request" scope. Caches that context
within the request itself.
getSessionContext
public static org.apache.commons.jxpath.JXPathContext getSessionContext(javax.servlet.http.HttpSession session, javax.servlet.ServletContext servletContext)
- Returns a JXPathContext bound to the "session" scope. Caches that context
within the session itself.
getApplicationContext
public static org.apache.commons.jxpath.JXPathContext getApplicationContext(javax.servlet.ServletContext servletContext)
- Returns a JXPathContext bound to the "application" scope. Caches that
context within the servlet context itself.
|
|||||||||
| Home >> All >> org >> apache >> commons >> jxpath >> [ servlet overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.commons.jxpath.servlet.JXPathServletContexts