FileDocCategorySizeDatePackage
PageContextImpl.javaAPI DocGlassfish v2 API35404Fri May 04 22:32:54 BST 2007org.apache.jasper.runtime

PageContextImpl

public class PageContextImpl extends javax.servlet.jsp.PageContext
Implementation of the PageContext class from the JSP spec.
author
Anil K. Vijendran
author
Larry Cable
author
Hans Bergsten
author
Pierre Delisle
author
Mark Roth
author
Jan Luehe
author
Kin-man Chung

Fields Summary
private static com.sun.org.apache.commons.logging.Log
log
private BodyContentImpl[]
outs
private int
depth
private Servlet
servlet
private ServletConfig
config
private ServletContext
context
private javax.servlet.jsp.JspFactory
factory
private boolean
needsSession
private String
errorPageURL
private int
bufferSize
private JspApplicationContextImpl
jspApplicationContext
private ELResolver
elResolver
private ELContext
elContext
private HashMap
attributes
private boolean
isNametableInitialized
private ServletRequest
request
private ServletResponse
response
private HttpSession
session
private javax.servlet.jsp.JspWriter
out
private JspWriterImpl
baseOut
Constructors Summary
PageContextImpl(javax.servlet.jsp.JspFactory factory)


    /*
     * Constructor.
     */
      
        this.factory = factory;
	this.outs = new BodyContentImpl[0];
	this.attributes = new HashMap(16);
	this.depth = -1;
    
Methods Summary
private void_initialize(javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)


	// initialize state
	this.servlet = servlet;
	this.config = servlet.getServletConfig();
	this.context = config.getServletContext();
	this.needsSession = needsSession;
	this.errorPageURL = errorPageURL;
	this.bufferSize = bufferSize;
	this.request = request;
 	this.response = response;

	// Setup session (if required)
	if (request instanceof HttpServletRequest && needsSession)
	    this.session = ((HttpServletRequest)request).getSession();
	if (needsSession && session == null)
	    throw new IllegalStateException
                ("Page needs a session and none is available");

        // initialize the initial out ...
        depth = -1;
        if (this.baseOut == null) {
            this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
        } else {
            this.baseOut.init(response, bufferSize, autoFlush);
        }
        this.out = baseOut;

        this.isNametableInitialized = false;
        setAttribute(Constants.FIRST_REQUEST_SEEN, "true", APPLICATION_SCOPE);

    
private java.lang.ObjectdoFindAttribute(java.lang.String name)


        if (!isNametableInitialized) {
            initializePageScopeNameTable();
        }

        Object o = attributes.get(name);
        if (o != null)
            return o;

        o = request.getAttribute(name);
        if (o != null)
            return o;

 	if (session != null) {
	    try {
	        o = session.getAttribute(name);
 	    } catch (IllegalStateException ex) {
 	        // Session has been invalidated.
                // Ignore and fall through to application scope.
 	    }

 	    if (o != null) return o;
 	}

        return context.getAttribute(name);
    
private java.lang.ObjectdoGetAttribute(java.lang.String name)

        if (!isNametableInitialized) {
            initializePageScopeNameTable();
        }
        return attributes.get(name);
    
private java.lang.ObjectdoGetAttribute(java.lang.String name, int scope)

        switch (scope) {
            case PAGE_SCOPE:
                if (!isNametableInitialized) {
                    initializePageScopeNameTable();
                }
                return attributes.get(name);

            case REQUEST_SCOPE:
                return request.getAttribute(name);

            case SESSION_SCOPE:
                if (session == null) {
                    throw new IllegalStateException(
                        Localizer.getMessage("jsp.error.page.noSession"));
                }
                return session.getAttribute(name);

            case APPLICATION_SCOPE:
                return context.getAttribute(name);

            default:
                throw new IllegalArgumentException("Invalid scope");
        }
    
private java.util.EnumerationdoGetAttributeNamesInScope(int scope)

        switch (scope) {
        case PAGE_SCOPE:
            if (!isNametableInitialized) {
                initializePageScopeNameTable();
            }
            return Collections.enumeration(attributes.keySet());
            
        case REQUEST_SCOPE:
            return request.getAttributeNames();

        case SESSION_SCOPE:
            if (session == null) {
            throw new IllegalStateException(
                        Localizer.getMessage("jsp.error.page.noSession"));
            }
            return session.getAttributeNames();

        case APPLICATION_SCOPE:
            return context.getAttributeNames();

        default:
            throw new IllegalArgumentException("Invalid scope");
        }
    
private intdoGetAttributeScope(java.lang.String name)


        if (!isNametableInitialized) {
            initializePageScopeNameTable();
        }

        if (attributes.get(name) != null)
            return PAGE_SCOPE;

        if (request.getAttribute(name) != null)
            return REQUEST_SCOPE;

        if (session != null) {
            try {
                if (session.getAttribute(name) != null)
                    return SESSION_SCOPE;
            } catch (IllegalStateException ex) {
 	        // Session has been invalidated.
                // Ignore and fall through to application scope.
            }
        }

        if (context.getAttribute(name) != null)
            return APPLICATION_SCOPE;

        return 0;
    
private voiddoHandlePageException(java.lang.Throwable t)


        if (errorPageURL != null && !errorPageURL.equals("")) {

            /*
             * Set request attributes.
             * Do not set the javax.servlet.error.exception attribute here
             * (instead, set in the generated servlet code for the error page)
             * in order to prevent the ErrorReportValve, which is invoked as
             * part of forwarding the request to the error page, from
             * throwing it if the response has not been committed (the response
             * will have been committed if the error page is a JSP page).
             */
            request.setAttribute("javax.servlet.jsp.jspException", t);
            request.setAttribute("javax.servlet.error.status_code",
                Integer.valueOf(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
            request.setAttribute("javax.servlet.error.request_uri",
            ((HttpServletRequest) request).getRequestURI());
            request.setAttribute("javax.servlet.error.servlet_name",
                     config.getServletName());
            try {
                forward(errorPageURL);
            } catch (IllegalStateException ise) {
                include(errorPageURL);
            }

            // The error page could be inside an include.

            Object newException = request.getAttribute("javax.servlet.error.exception");

            // t==null means the attribute was not set.
            if( (newException!= null) && (newException==t) ) {
                request.removeAttribute("javax.servlet.error.exception");
            }

            // now clear the error code - to prevent double handling.
            request.removeAttribute("javax.servlet.error.status_code");
            request.removeAttribute("javax.servlet.error.request_uri");
            request.removeAttribute("javax.servlet.error.status_code");
            request.removeAttribute("javax.servlet.jsp.jspException");

        } else {

            // Otherwise throw the exception wrapped inside a ServletException.
            // Set the exception as the root cause in the ServletException
            // to get a stack trace for the real problem
            if (t instanceof IOException) throw (IOException)t;
            if (t instanceof ServletException) throw (ServletException)t;
            if (t instanceof RuntimeException) throw (RuntimeException)t;

            Throwable rootCause = null;
            if (t instanceof JspException) {
                rootCause = ((JspException) t).getRootCause();
            } else if (t instanceof ELException) {
                rootCause = t.getCause();
            }

            if (rootCause != null) {
                throw new ServletException(t.getMessage(), rootCause);
            }
                 
            throw new ServletException(t);
        }
    
private voiddoRemoveAttribute(java.lang.String name, int scope)

        switch (scope) {
        case PAGE_SCOPE:
            if (!isNametableInitialized) {
                initializePageScopeNameTable();
            }
            attributes.remove(name);
            break;

        case REQUEST_SCOPE:
            request.removeAttribute(name);
            break;

        case SESSION_SCOPE:
            if (session == null) {
            throw new IllegalStateException(
                        Localizer.getMessage("jsp.error.page.noSession"));
            }
            session.removeAttribute(name);
            break;

        case APPLICATION_SCOPE:
            context.removeAttribute(name);
            break;
            
        default:
            throw new IllegalArgumentException("Invalid scope");
        }
    
private voiddoRemoveAttribute(java.lang.String name)

        removeAttribute(name, PAGE_SCOPE);
        removeAttribute(name, REQUEST_SCOPE);
        if( session != null ) {
            try {
                removeAttribute(name, SESSION_SCOPE);
            } catch (IllegalStateException ex) {
                // Session has been invalidated.
                // Ignore and fall through to application scope.
            }
        }
        removeAttribute(name, APPLICATION_SCOPE);
    
private voiddoSetAttribute(java.lang.String name, java.lang.Object attribute)

        if (attribute != null) {
            if (!isNametableInitialized) {
                initializePageScopeNameTable();
            }
            attributes.put(name, attribute);
        } else {
            removeAttribute(name, PAGE_SCOPE);
        }
    
private voiddoSetAttribute(java.lang.String name, java.lang.Object o, int scope)

        if (o != null) {
            switch (scope) {
            case PAGE_SCOPE:
                if (!isNametableInitialized) {
                    initializePageScopeNameTable();
                }
                attributes.put(name, o);
                break;

            case REQUEST_SCOPE:
                request.setAttribute(name, o);
                break;

            case SESSION_SCOPE:
                if (session == null) {
                    throw new IllegalStateException(
                        Localizer.getMessage("jsp.error.page.noSession"));
                }
                session.setAttribute(name, o);
                break;

            case APPLICATION_SCOPE:
                context.setAttribute(name, o);
                break;

            default:
                throw new IllegalArgumentException("Invalid scope");
            }
        } else {
            removeAttribute(name, scope);
        }
    
public static java.lang.ObjectevaluateExpression(java.lang.String expression, java.lang.Class expectedType, javax.servlet.jsp.PageContext pageContext, ProtectedFunctionMapper functionMap)
Evaluates an EL expression

param
expression The expression to be evaluated
param
expectedType The expected resulting type
param
pageContext The page context
param
functionMap Maps prefix and name to Method
return
The result of the evaluation

	Object retValue;
        if (SecurityUtil.isPackageProtectionEnabled()){
            try {
                retValue = AccessController.doPrivileged(
			new PrivilegedExceptionAction(){

                    public Object run() throws Exception{
                        ELContextImpl elContext =
                            (ELContextImpl) pageContext.getELContext();
                        elContext.setFunctionMapper(functionMap);
                        ExpressionFactory expFactory = getExpressionFactory(pageContext);
                        ValueExpression expr =
                             expFactory.createValueExpression(
                                                   elContext,
                                                   expression,
                                                   expectedType);
                        return expr.getValue(elContext);
                    }
                });
            } catch (PrivilegedActionException ex) {
                Exception realEx = ex.getException();
		if (realEx instanceof ELException) {
		    throw (ELException) realEx;
		} else {
		    throw new ELException(realEx);
		}
            }
        } else {
            ELContextImpl elContext = (ELContextImpl)pageContext.getELContext();
            elContext.setFunctionMapper(functionMap);
            ExpressionFactory expFactory = getExpressionFactory(pageContext);
            ValueExpression expr = expFactory.createValueExpression(
                                           elContext,
                                           expression,
                                           expectedType);
            retValue = expr.getValue(elContext);
        }
	return retValue;
    
public java.lang.ObjectfindAttribute(java.lang.String name)

        if (SecurityUtil.isPackageProtectionEnabled()){
            return AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    if (name == null) {
                        throw new NullPointerException(
                                Localizer.getMessage("jsp.error.attribute.null_name"));
                    }

                    return doFindAttribute(name);
                }
            });
        } else {
            if (name == null) {
                throw new NullPointerException(
                        Localizer.getMessage("jsp.error.attribute.null_name"));
            }

            return doFindAttribute(name);
        }
    
public voidforward(java.lang.String relativeUrlPath)


        // JSP.4.5 If the buffer was flushed, throw IllegalStateException
        try {
            out.clear();
        } catch (IOException ex) {
            IllegalStateException ise =
                new IllegalStateException(Localizer.getMessage(
                            "jsp.error.attempt_to_clear_flushed_buffer"));
            ise.initCause(ex);
            throw ise;
        }

        // Make sure that the response object is not the wrapper for include
        while (response instanceof ServletResponseWrapperInclude) {
            response = ((ServletResponseWrapperInclude)response).getResponse();
        }

        final String path = getAbsolutePathRelativeToContext(relativeUrlPath);
        String includeUri
            = (String) request.getAttribute(Constants.INC_SERVLET_PATH);
            
        final ServletResponse fresponse = response;
        final ServletRequest frequest = request;
            
        if (includeUri != null)
            request.removeAttribute(Constants.INC_SERVLET_PATH);
        try {
            context.getRequestDispatcher(path).forward(request, response);
        } finally {
            if (includeUri != null)
                request.setAttribute(Constants.INC_SERVLET_PATH, includeUri);
            request.setAttribute(Constants.FORWARD_SEEN, "true");
        }
    
private final java.lang.StringgetAbsolutePathRelativeToContext(java.lang.String relativeUrlPath)

        String path = relativeUrlPath;

        if (!path.startsWith("/")) {
	    String uri = (String)
		request.getAttribute("javax.servlet.include.servlet_path");
	    if (uri == null)
		uri = ((HttpServletRequest) request).getServletPath();
            String baseURI = uri.substring(0, uri.lastIndexOf('/"));
            path = baseURI+'/"+path;
        }

        return path;
    
public java.lang.ObjectgetAttribute(java.lang.String name)


        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            return AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    return doGetAttribute(name);
                }
            });
        } else {
            return doGetAttribute(name);
        }

    
public java.lang.ObjectgetAttribute(java.lang.String name, int scope)


        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            return AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    return doGetAttribute(name, scope);
                }
            });
        } else {
            return doGetAttribute(name, scope);
        }

    
public java.util.EnumerationgetAttributeNamesInScope(int scope)

        if (SecurityUtil.isPackageProtectionEnabled()){
            return (Enumeration<String>)
                    AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    return doGetAttributeNamesInScope(scope);
                }
            });
        } else {
            return doGetAttributeNamesInScope(scope);
        }
    
public intgetAttributesScope(java.lang.String name)


        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            return ((Integer)AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    return Integer.valueOf(doGetAttributeScope(name));
                }
            })).intValue();
        } else {
            return doGetAttributeScope(name);
        }
    
public javax.el.ELContextgetELContext()

        if (elContext == null) {
            elContext = getJspApplicationContext().createELContext(
                            getELResolver());
            elContext.putContext(javax.servlet.jsp.JspContext.class, this);
            ((ELContextImpl)elContext).setVariableMapper(
                new VariableMapperImpl());
        }
        return elContext;
    
private javax.el.ELResolvergetELResolver()

                                                                                
        if (elResolver == null) {
            // Create a CompositeELResolver
            CompositeELResolver celResolver = new CompositeELResolver();
                                                                                
            celResolver.add(new ImplicitObjectELResolver());
            // Add ELResolvers registered in JspApplicationContext
            JspApplicationContextImpl jaContext = getJspApplicationContext();
            Iterator<ELResolver> it = jaContext.getELResolvers();
            while (it.hasNext()) {
                celResolver.add(it.next());
            }
            celResolver.add(new MapELResolver());
            celResolver.add(new ResourceBundleELResolver());
            celResolver.add(new ListELResolver());
            celResolver.add(new ArrayELResolver());
            celResolver.add(new BeanELResolver());
            celResolver.add(new ScopedAttributeELResolver());
            elResolver = celResolver;
        }
        return elResolver;
    
public java.lang.ExceptiongetException()
Returns the exception associated with this page context, if any. Added wrapping for Throwables to avoid ClassCastException (see Bugzilla 31171 for details).

return
The Exception associated with this page context, if any.


        Throwable t = JspRuntimeLibrary.getThrowable(request);

        // Only wrap if needed
        if((t != null) && (! (t instanceof Exception))) {
            t = new JspException(t);
        }

        return (Exception) t;
    
public javax.servlet.jsp.el.ExpressionEvaluatorgetExpressionEvaluator()
Provides programmatic access to the ExpressionEvaluator. The JSP Container must return a valid instance of an ExpressionEvaluator that can parse EL expressions.

        return new ExpressionEvaluatorImpl(this);
    
private static javax.el.ExpressionFactorygetExpressionFactory(javax.servlet.jsp.PageContext pageContext)


        PageContextImpl pc =
            (PageContextImpl) JspContextWrapper.getRootPageContext(pageContext);
        return pc.getJspApplicationContext().getExpressionFactory();
    
JspApplicationContextImplgetJspApplicationContext()

        if (jspApplicationContext == null) {
            jspApplicationContext =
                JspApplicationContextImpl.findJspApplicationContext(context);
        }
        return jspApplicationContext;
    
public static javax.el.MethodExpressiongetMethodExpression(java.lang.String expression, javax.servlet.jsp.PageContext pageContext, javax.el.FunctionMapper functionMap, java.lang.Class expectedType, java.lang.Class[] paramTypes)

                                                                                
        ELContextImpl elctxt = (ELContextImpl)pageContext.getELContext();
        elctxt.setFunctionMapper(functionMap);
        ExpressionFactory expFactory = getExpressionFactory(pageContext);
        return expFactory.createMethodExpression(
                                    elctxt,
                                    expression,
                                    expectedType,
                                    paramTypes);
    
public javax.servlet.jsp.JspWritergetOut()

	return out;
    
public java.lang.ObjectgetPage()

 return servlet; 
public javax.servlet.ServletRequestgetRequest()

 return request; 
public javax.servlet.ServletResponsegetResponse()

 return response; 
public javax.servlet.ServletgetServlet()

 return servlet; 
public javax.servlet.ServletConfiggetServletConfig()

 return config; 
public javax.servlet.ServletContextgetServletContext()

	return config.getServletContext();
    
public javax.servlet.http.HttpSessiongetSession()

 return session; 
public static javax.el.ValueExpressiongetValueExpression(java.lang.String expression, javax.servlet.jsp.PageContext pageContext, java.lang.Class expectedType, javax.el.FunctionMapper functionMap)

        // ELResolvers are not used in createValueExpression
        ELContextImpl elctxt = (ELContextImpl)pageContext.getELContext();
        elctxt.setFunctionMapper(functionMap);
        ExpressionFactory expFactory = getExpressionFactory(pageContext);
        return expFactory.createValueExpression(elctxt,
                                                expression,
                                                expectedType);
    
public javax.servlet.jsp.el.VariableResolvergetVariableResolver()

        return new VariableResolverImpl(this);
    
public voidhandlePageException(java.lang.Exception ex)

        // Should never be called since handleException() called with a
        // Throwable in the generated servlet.
        handlePageException((Throwable) ex);
    
public voidhandlePageException(java.lang.Throwable t)

        if (t == null)
            throw new NullPointerException("null Throwable");

        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(new PrivilegedExceptionAction(){
                    public Object run() throws Exception{
                        doHandlePageException(t);
                        return null;
                    }
                });
            } catch (PrivilegedActionException e){
                Exception ex =  e.getException();
                if (ex instanceof IOException){
                    throw (IOException)ex;
                } else {
                    throw (ServletException)ex;
                }
            }
        } else {
            doHandlePageException(t);
        }

    
public voidinclude(java.lang.String relativeUrlPath)

        JspRuntimeLibrary.include(request, response, relativeUrlPath, out,
				  true);
    
public voidinclude(java.lang.String relativeUrlPath, boolean flush)

        JspRuntimeLibrary.include(request, response, relativeUrlPath, out,
				  flush);
    
public voidinitialize(javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)


	_initialize(servlet, request, response, errorPageURL, needsSession,
		    bufferSize, autoFlush);
    
private voidinitializePageScopeNameTable()

        isNametableInitialized = true;
        // register names/values as per spec
        setAttribute(OUT, this.out);
        setAttribute(REQUEST, request);
        setAttribute(RESPONSE, response);

        if (session != null)
            setAttribute(SESSION, session);

        setAttribute(PAGE, servlet);
        setAttribute(CONFIG, config);
        setAttribute(PAGECONTEXT, this);
        setAttribute(APPLICATION, context);
    
public javax.servlet.jsp.JspWriterpopBody()

        depth--;
        if (depth >= 0) {
            out = outs[depth];
        } else {
            out = baseOut;
        }

	// Update the value of the "out" attribute in the page scope
	// attribute namespace of this PageContext
	setAttribute(OUT, out);

        return out;
    
public javax.servlet.jsp.tagext.BodyContentpushBody()

	return (BodyContent) pushBody(null);
    
public javax.servlet.jsp.JspWriterpushBody(java.io.Writer writer)

        depth++;
        if (depth >= outs.length) {
            BodyContentImpl[] newOuts = new BodyContentImpl[depth + 1];
            for (int i=0; i<outs.length; i++) {
                newOuts[i] = outs[i];
            }
            newOuts[depth] = new BodyContentImpl(out);
            outs = newOuts;
        }

	outs[depth].setWriter(writer);
        out = outs[depth];

	// Update the value of the "out" attribute in the page scope
	// attribute namespace of this PageContext
	setAttribute(OUT, out);

        return outs[depth];
    
public voidrelease()

        out = baseOut;
	try {
            // Do not flush the buffer even if we're not included (i.e.
            // we are the main page. The servlet will flush it and close
            // the stream.
            ((JspWriterImpl)out).flushBuffer();
	} catch (IOException ex) {
	    log.warn("Internal error flushing the buffer in release()");
	}

	servlet = null;
	config = null;
	context = null;
        elContext = null;
        elResolver = null;
        jspApplicationContext = null;
	needsSession = false;
	errorPageURL = null;
	bufferSize = JspWriter.DEFAULT_BUFFER;
	request = null;
	response = null;
        depth = -1;
	baseOut.recycle();
	session = null;

	attributes.clear();
    
public voidremoveAttribute(java.lang.String name, int scope)


        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }
        if (SecurityUtil.isPackageProtectionEnabled()){
            AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    doRemoveAttribute(name, scope);
                    return null;
                }
            });
        } else {
            doRemoveAttribute(name, scope);
        }
    
public voidremoveAttribute(java.lang.String name)


        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    doRemoveAttribute(name);
                    return null;
                }
            });
        } else {
            doRemoveAttribute(name);
        }
    
public voidsetAttribute(java.lang.String name, java.lang.Object attribute)


        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    doSetAttribute(name, attribute);
                    return null;
                }
            });
        } else {
            doSetAttribute(name, attribute);
        }
    
public voidsetAttribute(java.lang.String name, java.lang.Object o, int scope)


        if (name == null) {
            throw new NullPointerException(
                    Localizer.getMessage("jsp.error.attribute.null_name"));
        }

        if (SecurityUtil.isPackageProtectionEnabled()){
            AccessController.doPrivileged(new PrivilegedAction(){
                public Object run(){
                    doSetAttribute(name, o, scope);
                    return null;
                }
            });
        } else {
            doSetAttribute(name, o, scope);
        }

    
public static voidsetMethodVariable(javax.servlet.jsp.PageContext pageContext, java.lang.String variable, javax.el.MethodExpression expression)

        ExpressionFactory expFactory = getExpressionFactory(pageContext);
        ValueExpression exp =
            expFactory.createValueExpression(expression, Object.class);
        setValueVariable(pageContext, variable, exp);
    
public static voidsetValueVariable(javax.servlet.jsp.PageContext pageContext, java.lang.String variable, javax.el.ValueExpression expression)

        ELContextImpl elctxt = (ELContextImpl)pageContext.getELContext();
        elctxt.getVariableMapper().setVariable(variable, expression);