com.caucho.jsp
Class PageContextImpl

java.lang.Object
  extended by javax.servlet.jsp.JspContext
      extended by javax.servlet.jsp.PageContext
          extended by com.caucho.jsp.PageContextImpl
All Implemented Interfaces:
ExprEnv, JstlPageContext, VariableResolver
Direct Known Subclasses:
InitPageContextImpl, PageContextWrapper

public class PageContextImpl
extends PageContext
implements ExprEnv, JstlPageContext, VariableResolver


Nested Class Summary
 class PageContextImpl.PageELContext
           
 class PageContextImpl.PageFunctionMapper
           
 class PageContextImpl.PageVarEnv
          Represents the XPath environment for this page.
 class PageContextImpl.PageVariableMapper
           
 
Field Summary
protected  boolean _isFilled
           
 
Fields inherited from class javax.servlet.jsp.PageContext
APPLICATION, APPLICATION_SCOPE, CONFIG, EXCEPTION, OUT, PAGE, PAGE_SCOPE, PAGECONTEXT, REQUEST, REQUEST_SCOPE, RESPONSE, SESSION, SESSION_SCOPE
 
Constructor Summary
PageContextImpl(WebApp webApp, java.util.HashMap<java.lang.String,java.lang.reflect.Method> functionMap)
           
PageContextImpl(WebApp webApp, Servlet servlet)
           
 
Method Summary
 void applicationSetOrRemove(java.lang.String var, java.lang.Object value)
          Set/Remove an webApp attribute.
protected  void clearAttributes()
           
 ValueExpression createExpr(ValueExpression expr, java.lang.String exprString, java.lang.Class type)
          Creates an expression.
 void defaultSetOrRemove(java.lang.String var, java.lang.Object value)
          Set/Remove a page attribute.
 java.lang.StringBuilder encode(java.lang.String relativeUrl)
           
 java.lang.StringBuilder encode(java.lang.StringBuilder sb, java.lang.String query)
           
protected  void fillAttribute()
          Fills the predefined page content _attributes with their values.
 java.lang.Object findAttribute(java.lang.String name)
          Finds an attribute in any of the scopes from page to webApp.
 void forward(java.lang.String relativeUrl)
          Forward a subrequest relative to the current url.
 void forward(java.lang.String relativeUrl, java.lang.String query)
          Include another servlet into the current output stream.
 WebApp getApplication()
          Returns the page's webApp.
 java.lang.Object getAttribute(java.lang.String name)
          Returns the page attribute with the given name.
 java.lang.Object getAttribute(java.lang.String name, int scope)
          Gets an attribute in a given scope.
 java.util.Enumeration<java.lang.String> getAttributeNames(int scope)
           
 java.util.Enumeration<java.lang.String> getAttributeNamesInScope(int scope)
          Lists attribute names in a given scope.
 int getAttributesScope(java.lang.String name)
          Return the scope of the named attribute.
 LocalizationContext getBundle(java.lang.String name)
          Returns the localized message appropriate for the current context.
 HttpServletRequest getCauchoRequest()
          Returns the servlet response for the page.
 CauchoResponse getCauchoResponse()
          Returns the servlet response for the page.
 ELContext getELContext()
          Returns the expression evaluator
 ErrorData getErrorData()
          Returns the error data
 java.lang.String getErrorPage()
          Returns the page's error page.
 java.lang.Exception getException()
          Returns the exception for error pages.
 ExpressionEvaluator getExpressionEvaluator()
          Returns the expression evaluator
 java.util.Locale getLocale()
          Returns the currently active locale.
static java.util.Locale getLocale(java.lang.String value, java.lang.String variant)
           
 java.lang.String getLocalizedMessage(java.lang.Object lc, java.lang.String key, java.lang.Object[] args, java.lang.String basename)
          Returns the localized message appropriate for the current context.
 java.lang.String getLocalizedMessage(java.lang.String key, java.lang.Object[] args, java.lang.String basename)
          Returns the localized message appropriate for the current context.
 org.w3c.dom.Node getNodeEnv()
          Returns the XPath node environment corresponding to this page
 JspWriter getOut()
          Returns the current writer.
 java.lang.Object getPage()
          Returns the underlying servlet for the page.
 HttpServletRequest getRequest()
          Returns the servlet request for the page.
 HttpServletResponse getResponse()
          Returns the servlet response for the page.
 ServletConfig getServletConfig()
          Returns the servletConfig for the JSP page.
 ServletContext getServletContext()
          Returns the page's servlet context.
 HttpSession getSession()
          Returns the request's session.
 HttpSession getSessionScope()
          Returns the session, throwing an IllegalStateException if it's not available.
 java.lang.Throwable getThrowable()
          Returns the Throwable stored by the error page.
 java.io.PrintWriter getTopWriter()
          Returns the top writer.
 VarEnv getVarEnv()
          Returns the XPath variable environment corresponding to this page
 VariableResolver getVariableResolver()
          Returns the variable resolver
 void handlePageException(java.lang.Exception e)
          Handles an exception caught in the JSP page.
 void handlePageException(java.lang.Throwable e)
          Handles an exception caught in the JSP page.
 void include(java.lang.String relativeUrl)
          Includes the a page relative to the current URL.
 void include(java.lang.String relativeUrl, boolean flush)
          Include another servlet into the current output stream.
 void include(java.lang.String relativeUrl, java.lang.String query, boolean flush)
          Include another servlet into the current output stream.
protected  void init()
           
 void initialize(Servlet servlet, ServletRequest request, ServletResponse response, java.lang.String errorPage, boolean needsSession, int bufferSize, boolean autoFlush)
          Internal routine to initialize the PageContext for a page.
 void initialize(Servlet servlet, WebApp app, ServletRequest request, ServletResponse response, java.lang.String errorPage, HttpSession session, int bufferSize, boolean autoFlush, boolean isPrintNullAsBlank)
           
 java.lang.String invoke(JspFragment fragment)
          Evaluates the fragment, returing the string value.
 java.io.Reader invokeReader(JspFragment fragment)
          Evaluates the fragment, returing a reader
 java.lang.String invokeTrim(JspFragment fragment)
          Evaluates the fragment, returing the string value.
 boolean isIgnoreException()
          Returns true if the EL ignores exceptions
 void pageSetOrRemove(java.lang.String var, java.lang.Object value)
          Set/Remove a page attribute.
 JspWriter popAndReleaseBody()
          Pops the BodyContent from the JspWriter stack.
 JspWriter popBody()
          Pops the BodyContent from the JspWriter stack.
static void printBody(BodyContentImpl body, boolean isEscaped)
           
 BodyContent pushBody()
          Pushes a new BodyContent onto the JspWriter stack.
 JspWriter pushBody(java.io.Writer writer)
          Pushes a new writer onto the JspWriter stack.
 java.lang.Object putAttribute(java.lang.String name, java.lang.Object attribute)
          Sets the page attribute with the given name.
 void release()
          Releases the context.
 void releaseBody(BodyContentImpl out)
           
 void removeAttribute(java.lang.String name)
          Removes a named attribute from the page context.
 void removeAttribute(java.lang.String name, int scope)
          Removes an attribute in a given scope.
 void requestSetOrRemove(java.lang.String var, java.lang.Object value)
          Set/Remove a request attribute.
 java.lang.Object resolveVariable(java.lang.String name)
          Finds an attribute in any of the scopes from page to webApp.
 void sessionSetOrRemove(java.lang.String var, java.lang.Object value)
          Set/Remove a session attribute.
 void setAttribute(java.lang.String name, java.lang.Object attribute)
          Sets the page attribute with the given name.
 void setAttribute(java.lang.String name, java.lang.Object value, int scope)
          Sets an attribute in a given scope.
 void setErrorPage(java.lang.String errorPage)
          Sets the page's error page.
 java.util.Map<java.lang.String,java.lang.Object> setMap(java.util.Map<java.lang.String,java.lang.Object> map)
          Sets the attribute map.
 void setNodeEnv(org.w3c.dom.Node node)
          Returns the XPath node environment corresponding to this page
protected  void setOut(JspWriter out)
           
 JspWriter setWriter(JspWriter oldWriter)
          Pops the BodyContent from the JspWriter stack.
static boolean toBoolean(java.lang.String value)
          Parses a boolean value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_isFilled

protected boolean _isFilled
Constructor Detail

PageContextImpl

public PageContextImpl(WebApp webApp,
                       Servlet servlet)

PageContextImpl

public PageContextImpl(WebApp webApp,
                       java.util.HashMap<java.lang.String,java.lang.reflect.Method> functionMap)
Method Detail

initialize

public void initialize(Servlet servlet,
                       ServletRequest request,
                       ServletResponse response,
                       java.lang.String errorPage,
                       boolean needsSession,
                       int bufferSize,
                       boolean autoFlush)
Description copied from class: PageContext
Internal routine to initialize the PageContext for a page.

Specified by:
initialize in class PageContext

initialize

public void initialize(Servlet servlet,
                       WebApp app,
                       ServletRequest request,
                       ServletResponse response,
                       java.lang.String errorPage,
                       HttpSession session,
                       int bufferSize,
                       boolean autoFlush,
                       boolean isPrintNullAsBlank)

init

protected void init()

setOut

protected void setOut(JspWriter out)

clearAttributes

protected void clearAttributes()

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the page attribute with the given name.

Specified by:
getAttribute in class PageContext
Parameters:
name - the attribute name.
Returns:
the attribute's value.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object attribute)
Sets the page attribute with the given name.

Specified by:
setAttribute in class PageContext
Parameters:
name - the attribute name.
attribute - the new value

putAttribute

public java.lang.Object putAttribute(java.lang.String name,
                                     java.lang.Object attribute)
Sets the page attribute with the given name.

Parameters:
name - the attribute name.
attribute - the new value

removeAttribute

public void removeAttribute(java.lang.String name)
Removes a named attribute from the page context.

Specified by:
removeAttribute in class PageContext
Parameters:
name - the name of the attribute to remove

fillAttribute

protected void fillAttribute()
Fills the predefined page content _attributes with their values.


getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     int scope)
Description copied from class: JspContext
Gets an attribute in a given scope. You should use the scope-specific routines instead, like request.getAttribute.

Specified by:
getAttribute in class JspContext
Parameters:
name - attribute name
scope - attribute scope

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value,
                         int scope)
Description copied from class: JspContext
Sets an attribute in a given scope. You should use the scope-specific routines instead, like request.setAttribute.

Specified by:
setAttribute in class JspContext
Parameters:
name - attribute name
value - attribute value
scope - attribute scope

removeAttribute

public void removeAttribute(java.lang.String name,
                            int scope)
Description copied from class: JspContext
Removes an attribute in a given scope. You should use the scope-specific routines instead, like request.removeAttribute.

Specified by:
removeAttribute in class JspContext

getAttributeNames

public java.util.Enumeration<java.lang.String> getAttributeNames(int scope)

getAttributeNamesInScope

public java.util.Enumeration<java.lang.String> getAttributeNamesInScope(int scope)
Description copied from class: JspContext
Lists attribute names in a given scope. You should use the scope-specific routines instead, like request.getAttributeNames

Specified by:
getAttributeNamesInScope in class JspContext

findAttribute

public java.lang.Object findAttribute(java.lang.String name)
Finds an attribute in any of the scopes from page to webApp.

Specified by:
findAttribute in class JspContext
Parameters:
name - the attribute name.
Returns:
the attribute value

getAttributesScope

public int getAttributesScope(java.lang.String name)
Return the scope of the named attribute.

Specified by:
getAttributesScope in class JspContext
Parameters:
name - the name of the attribute.
Returns:
the scope of the attribute

setMap

public java.util.Map<java.lang.String,java.lang.Object> setMap(java.util.Map<java.lang.String,java.lang.Object> map)
Sets the attribute map.


getOut

public JspWriter getOut()
Returns the current writer.

Specified by:
getOut in class PageContext

pushBody

public BodyContent pushBody()
Pushes a new BodyContent onto the JspWriter stack.

Overrides:
pushBody in class PageContext

pushBody

public JspWriter pushBody(java.io.Writer writer)
Pushes a new writer onto the JspWriter stack.

Overrides:
pushBody in class JspContext

popBody

public JspWriter popBody()
Pops the BodyContent from the JspWriter stack.

Overrides:
popBody in class JspContext
Returns:
the enclosing writer

popAndReleaseBody

public JspWriter popAndReleaseBody()
                            throws java.io.IOException
Pops the BodyContent from the JspWriter stack.

Returns:
the enclosing writer
Throws:
java.io.IOException

releaseBody

public void releaseBody(BodyContentImpl out)
                 throws java.io.IOException
Throws:
java.io.IOException

setWriter

public JspWriter setWriter(JspWriter oldWriter)
Pops the BodyContent from the JspWriter stack.

Parameters:
oldWriter - the old writer

getTopWriter

public java.io.PrintWriter getTopWriter()
                                 throws java.io.IOException
Returns the top writer.

Throws:
java.io.IOException

getPage

public java.lang.Object getPage()
Returns the underlying servlet for the page.

Specified by:
getPage in class PageContext

getRequest

public HttpServletRequest getRequest()
Returns the servlet request for the page.

Specified by:
getRequest in class PageContext

getResponse

public HttpServletResponse getResponse()
Returns the servlet response for the page.

Specified by:
getResponse in class PageContext

getCauchoResponse

public CauchoResponse getCauchoResponse()
Returns the servlet response for the page.


getCauchoRequest

public HttpServletRequest getCauchoRequest()
Returns the servlet response for the page.


getSession

public HttpSession getSession()
Description copied from class: PageContext
Returns the request's session.

Specified by:
getSession in class PageContext

getSessionScope

public HttpSession getSessionScope()
Returns the session, throwing an IllegalStateException if it's not available.


getServletConfig

public ServletConfig getServletConfig()
Description copied from class: PageContext
Returns the servletConfig for the JSP page.

Specified by:
getServletConfig in class PageContext

getServletContext

public ServletContext getServletContext()
Returns the page's servlet context.

Specified by:
getServletContext in class PageContext

getApplication

public WebApp getApplication()
Returns the page's webApp.


getErrorPage

public java.lang.String getErrorPage()
Returns the page's error page.


setErrorPage

public void setErrorPage(java.lang.String errorPage)
Sets the page's error page.


getException

public java.lang.Exception getException()
Description copied from class: PageContext
Returns the exception for error pages.

Specified by:
getException in class PageContext

getThrowable

public java.lang.Throwable getThrowable()
Returns the Throwable stored by the error page.


include

public void include(java.lang.String relativeUrl)
             throws ServletException,
                    java.io.IOException
Description copied from class: PageContext
Includes the a page relative to the current URL.

Specified by:
include in class PageContext
Throws:
ServletException
java.io.IOException

include

public void include(java.lang.String relativeUrl,
                    java.lang.String query,
                    boolean flush)
             throws ServletException,
                    java.io.IOException
Include another servlet into the current output stream.

Parameters:
relativeUrl - url relative to the current request.
Throws:
ServletException
java.io.IOException

encode

public java.lang.StringBuilder encode(java.lang.String relativeUrl)

encode

public java.lang.StringBuilder encode(java.lang.StringBuilder sb,
                                      java.lang.String query)

include

public void include(java.lang.String relativeUrl,
                    boolean flush)
             throws ServletException,
                    java.io.IOException
Include another servlet into the current output stream.

Specified by:
include in class PageContext
Parameters:
relativeUrl - url relative to the current request.
Throws:
ServletException
java.io.IOException

forward

public void forward(java.lang.String relativeUrl,
                    java.lang.String query)
             throws ServletException,
                    java.io.IOException
Include another servlet into the current output stream.

Parameters:
relativeUrl - url relative to the current request.
Throws:
ServletException
java.io.IOException

forward

public void forward(java.lang.String relativeUrl)
             throws ServletException,
                    java.io.IOException
Forward a subrequest relative to the current url. Absolute URLs are relative to the context root.

Specified by:
forward in class PageContext
Parameters:
relativeUrl - url relative to the current file
Throws:
ServletException
java.io.IOException

handlePageException

public void handlePageException(java.lang.Exception e)
                         throws ServletException,
                                java.io.IOException
Handles an exception caught in the JSP page.

Specified by:
handlePageException in class PageContext
Parameters:
e - the caught exception
Throws:
ServletException
java.io.IOException

handlePageException

public void handlePageException(java.lang.Throwable e)
                         throws ServletException,
                                java.io.IOException
Handles an exception caught in the JSP page.

Specified by:
handlePageException in class PageContext
Parameters:
e - the caught exception
Throws:
ServletException
java.io.IOException

getErrorData

public ErrorData getErrorData()
Returns the error data

Overrides:
getErrorData in class PageContext

getVariableResolver

public VariableResolver getVariableResolver()
Returns the variable resolver

Specified by:
getVariableResolver in class JspContext

getExpressionEvaluator

public ExpressionEvaluator getExpressionEvaluator()
Returns the expression evaluator

Specified by:
getExpressionEvaluator in class JspContext

getELContext

public ELContext getELContext()
Returns the expression evaluator

Specified by:
getELContext in class JspContext

release

public void release()
Releases the context.

Specified by:
release in class PageContext

getLocalizedMessage

public java.lang.String getLocalizedMessage(java.lang.String key,
                                            java.lang.Object[] args,
                                            java.lang.String basename)
Returns the localized message appropriate for the current context.

Specified by:
getLocalizedMessage in interface JstlPageContext

getLocalizedMessage

public java.lang.String getLocalizedMessage(java.lang.Object lc,
                                            java.lang.String key,
                                            java.lang.Object[] args,
                                            java.lang.String basename)
Returns the localized message appropriate for the current context.

Specified by:
getLocalizedMessage in interface JstlPageContext

getBundle

public LocalizationContext getBundle(java.lang.String name)
Returns the localized message appropriate for the current context.


getLocale

public java.util.Locale getLocale()
Returns the currently active locale.


getLocale

public static java.util.Locale getLocale(java.lang.String value,
                                         java.lang.String variant)

printBody

public static void printBody(BodyContentImpl body,
                             boolean isEscaped)
                      throws java.io.IOException
Throws:
java.io.IOException

invoke

public java.lang.String invoke(JspFragment fragment)
                        throws JspException,
                               java.io.IOException
Evaluates the fragment, returing the string value.

Throws:
JspException
java.io.IOException

invokeTrim

public java.lang.String invokeTrim(JspFragment fragment)
                            throws JspException,
                                   java.io.IOException
Evaluates the fragment, returing the string value.

Throws:
JspException
java.io.IOException

invokeReader

public java.io.Reader invokeReader(JspFragment fragment)
                            throws JspException,
                                   java.io.IOException
Evaluates the fragment, returing a reader

Throws:
JspException
java.io.IOException

toBoolean

public static boolean toBoolean(java.lang.String value)
Parses a boolean value.


defaultSetOrRemove

public void defaultSetOrRemove(java.lang.String var,
                               java.lang.Object value)
Set/Remove a page attribute.


pageSetOrRemove

public void pageSetOrRemove(java.lang.String var,
                            java.lang.Object value)
Set/Remove a page attribute.


requestSetOrRemove

public void requestSetOrRemove(java.lang.String var,
                               java.lang.Object value)
Set/Remove a request attribute.


sessionSetOrRemove

public void sessionSetOrRemove(java.lang.String var,
                               java.lang.Object value)
Set/Remove a session attribute.


applicationSetOrRemove

public void applicationSetOrRemove(java.lang.String var,
                                   java.lang.Object value)
Set/Remove an webApp attribute.


isIgnoreException

public boolean isIgnoreException()
Returns true if the EL ignores exceptions

Specified by:
isIgnoreException in interface ExprEnv

getVarEnv

public VarEnv getVarEnv()
Returns the XPath variable environment corresponding to this page


getNodeEnv

public org.w3c.dom.Node getNodeEnv()
Returns the XPath node environment corresponding to this page


setNodeEnv

public void setNodeEnv(org.w3c.dom.Node node)
Returns the XPath node environment corresponding to this page


createExpr

public ValueExpression createExpr(ValueExpression expr,
                                  java.lang.String exprString,
                                  java.lang.Class type)
Creates an expression.


resolveVariable

public java.lang.Object resolveVariable(java.lang.String name)
                                 throws ELException
Finds an attribute in any of the scopes from page to webApp.

Specified by:
resolveVariable in interface VariableResolver
Parameters:
name - the attribute name.
Returns:
the attribute value
Throws:
ELException