public abstract class JspContext extends Object
JspContext
serves as the base class for the
PageContext class and abstracts all information that is not specific
to servlets. This allows for Simple Tag Extensions to be used
outside of the context of a request/response Servlet.
The JspContext provides a number of facilities to the page/component author and page implementor, including:
Methods Intended for Container Generated Code
The following methods enable the management of nested JspWriter
streams to implement Tag Extensions: pushBody()
and
popBody()
Methods Intended for JSP authors
Some methods provide uniform access to the diverse objects
representing scopes.
The implementation must use the underlying machinery
corresponding to that scope, so information can be passed back and
forth between the underlying environment (e.g. Servlets) and JSP pages.
The methods are:
setAttribute()
, getAttribute()
,
findAttribute()
, removeAttribute()
,
getAttributesScope()
and
getAttributeNamesInScope()
.
The following methods provide convenient access to implicit objects:
getOut()
The following methods provide programmatic access to the
Expression Language evaluator:
getExpressionEvaluator()
, getVariableResolver()
Constructor and Description |
---|
JspContext()
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract Object |
findAttribute(String name)
Searches for the named attribute in page, request, session (if valid),
and application scope(s) in order and returns the value associated or
null.
|
abstract Object |
getAttribute(String name)
Returns the object associated with the name in the page scope or null
if not found.
|
abstract Object |
getAttribute(String name,
int scope)
Return the object associated with the name in the specified
scope or null if not found.
|
abstract Enumeration<String> |
getAttributeNamesInScope(int scope)
Enumerate all the attributes in a given scope.
|
abstract int |
getAttributesScope(String name)
Get the scope where a given attribute is defined.
|
abstract ELContext |
getELContext()
Returns the
ELContext associated with this
JspContext . |
abstract ExpressionEvaluator |
getExpressionEvaluator()
Deprecated.
As of JSP 2.1, replaced by
JspApplicationContext.getExpressionFactory() |
abstract JspWriter |
getOut()
The current value of the out object (a JspWriter).
|
abstract VariableResolver |
getVariableResolver()
Deprecated.
As of JSP 2.1, replaced by
ELContext.getELResolver() ,
which can be obtained by
jspContext.getELContext().getELResolver() . |
JspWriter |
popBody()
Return the previous JspWriter "out" saved by the matching
pushBody(), and update the value of the "out" attribute in
the page scope attribute namespace of the JspContext.
|
JspWriter |
pushBody(Writer writer)
Return a new JspWriter object that sends output to the
provided Writer.
|
abstract void |
removeAttribute(String name)
Remove the object reference associated with the given name
from all scopes.
|
abstract void |
removeAttribute(String name,
int scope)
Remove the object reference associated with the specified name
in the given scope.
|
abstract void |
setAttribute(String name,
Object value)
Register the name and value specified with page scope semantics.
|
abstract void |
setAttribute(String name,
Object value,
int scope)
Register the name and value specified with appropriate
scope semantics.
|
public JspContext()
public abstract void setAttribute(String name, Object value)
null
, this has the same
effect as calling
removeAttribute( name, PageContext.PAGE_SCOPE )
.name
- the name of the attribute to setvalue
- the value to associate with the name, or null if the
attribute is to be removed from the page scope.NullPointerException
- if the name is nullpublic abstract void setAttribute(String name, Object value, int scope)
null
,
this has the same effect as calling
removeAttribute( name, scope )
.name
- the name of the attribute to setvalue
- the object to associate with the name, or null if
the attribute is to be removed from the specified scope.scope
- the scope with which to associate the name/objectNullPointerException
- if the name is nullIllegalArgumentException
- if the scope is invalidIllegalStateException
- if the scope is
PageContext.SESSION_SCOPE but the page that was requested
does not participate in a session or the session has been
invalidated.public abstract Object getAttribute(String name)
name
- the name of the attribute to getNullPointerException
- if the name is nullpublic abstract Object getAttribute(String name, int scope)
name
- the name of the attribute to setscope
- the scope with which to associate the name/objectNullPointerException
- if the name is nullIllegalArgumentException
- if the scope is invalidIllegalStateException
- if the scope is
PageContext.SESSION_SCOPE but the page that was requested
does not participate in a session or the session has been
invalidated.public abstract Object findAttribute(String name)
name
- the name of the attribute to search forNullPointerException
- if the name is nullpublic abstract void removeAttribute(String name)
name
- The name of the object to remove.NullPointerException
- if the name is nullpublic abstract void removeAttribute(String name, int scope)
name
- The name of the object to remove.scope
- The scope where to look.IllegalArgumentException
- if the scope is invalidIllegalStateException
- if the scope is
PageContext.SESSION_SCOPE but the page that was requested
does not participate in a session or the session has been
invalidated.NullPointerException
- if the name is nullpublic abstract int getAttributesScope(String name)
name
- the name of the attribute to return the scope forNullPointerException
- if the name is nullpublic abstract Enumeration<String> getAttributeNamesInScope(int scope)
scope
- the scope to enumerate all the attributes forIllegalArgumentException
- if the scope is invalidIllegalStateException
- if the scope is
PageContext.SESSION_SCOPE but the page that was requested
does not participate in a session or the session has been
invalidated.public abstract JspWriter getOut()
public abstract ExpressionEvaluator getExpressionEvaluator()
JspApplicationContext.getExpressionFactory()
public abstract VariableResolver getVariableResolver()
ELContext.getELResolver()
,
which can be obtained by
jspContext.getELContext().getELResolver()
.public abstract ELContext getELContext()
ELContext
associated with this
JspContext
.
The ELContext
is created lazily and is reused if
it already exists. There is a new ELContext
for each
JspContext
.
The ELContext
must contain the ELResolver
described in the JSP specification (and in the javadocs for
JspApplicationContext.addELResolver(javax.el.ELResolver)
).
ELContext
associated with this
JspContext
.public JspWriter pushBody(Writer writer)
The returned JspWriter must implement all methods and behave as though it were unbuffered. More specifically:
writer
- The Writer for the returned JspWriter to send
output to.public JspWriter popBody()
Copyright © 2018 JBoss by Red Hat. All rights reserved.