Added: tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ELContextImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ELContextImpl.java?rev=379417&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ELContextImpl.java 
(added)
+++ tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ELContextImpl.java Tue 
Feb 21 02:57:35 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jasper.el;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+
+/**
+ * Implementation of ELContext
+ * 
+ * @author Jacob Hookom
+ */
+public class ELContextImpl extends ELContext {
+       
+       private final ELResolver resolver;
+       private FunctionMapper functionMapper;
+       private VariableMapper variableMapper;
+    
+    public ELContextImpl() {
+        this(ELResolverImpl.DefaultResolver);
+    }
+
+       public ELContextImpl(ELResolver resolver) {
+               this.resolver = resolver;
+       }
+
+       public ELResolver getELResolver() {
+               return this.resolver;
+       }
+
+       public FunctionMapper getFunctionMapper() {
+               return this.functionMapper;
+       }
+
+       public VariableMapper getVariableMapper() {
+               return this.variableMapper;
+       }
+       
+       public void setFunctionMapper(FunctionMapper functionMapper) {
+               this.functionMapper = functionMapper;
+       }
+       
+       public void setVariableMapper(VariableMapper variableMapper) {
+               this.variableMapper = variableMapper;
+       }
+
+}

Added: tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ELResolverImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ELResolverImpl.java?rev=379417&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ELResolverImpl.java 
(added)
+++ tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ELResolverImpl.java 
Tue Feb 21 02:57:35 2006
@@ -0,0 +1,129 @@
+package org.apache.jasper.el;
+
+import java.util.Iterator;
+
+import javax.el.ArrayELResolver;
+import javax.el.BeanELResolver;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ResourceBundleELResolver;
+import javax.servlet.jsp.el.VariableResolver;
+
+public class ELResolverImpl extends ELResolver {
+       
+       public final static ELResolver DefaultResolver = new 
CompositeELResolver();
+
+       static {
+               ((CompositeELResolver) DefaultResolver).add(new 
MapELResolver());
+               ((CompositeELResolver) DefaultResolver).add(new 
ResourceBundleELResolver());
+               ((CompositeELResolver) DefaultResolver).add(new 
ListELResolver());
+               ((CompositeELResolver) DefaultResolver).add(new 
ArrayELResolver());
+               ((CompositeELResolver) DefaultResolver).add(new 
BeanELResolver());
+       }
+
+       private final VariableResolver variableResolver;
+
+       public ELResolverImpl(VariableResolver variableResolver) {
+               this.variableResolver = variableResolver;
+       }
+
+       public Object getValue(ELContext context, Object base, Object property)
+                       throws NullPointerException, PropertyNotFoundException, 
ELException {
+               if (context == null) {
+                       throw new NullPointerException();
+               }
+
+               if (base == null) {
+                       context.setPropertyResolved(true);
+                       if (property != null) {
+                               try {
+                                       return 
this.variableResolver.resolveVariable(property
+                                                       .toString());
+                               } catch (javax.servlet.jsp.el.ELException e) {
+                                       throw new ELException(e.getMessage(), 
e.getCause());
+                               }
+                       }
+               }
+
+               if (!context.isPropertyResolved()) {
+                       return DefaultResolver.getValue(context, base, 
property);
+               }
+               return null;
+       }
+
+       public Class<?> getType(ELContext context, Object base, Object property)
+                       throws NullPointerException, PropertyNotFoundException, 
ELException {
+               if (context == null) {
+                       throw new NullPointerException();
+               }
+
+               if (base == null) {
+                       context.setPropertyResolved(true);
+                       if (property != null) {
+                               try {
+                                       Object obj = 
this.variableResolver.resolveVariable(property
+                                                       .toString());
+                                       return (obj != null) ? obj.getClass() : 
null;
+                               } catch (javax.servlet.jsp.el.ELException e) {
+                                       throw new ELException(e.getMessage(), 
e.getCause());
+                               }
+                       }
+               }
+
+               if (!context.isPropertyResolved()) {
+                       return DefaultResolver.getType(context, base, property);
+               }
+               return null;
+       }
+
+       public void setValue(ELContext context, Object base, Object property,
+                       Object value) throws NullPointerException,
+                       PropertyNotFoundException, PropertyNotWritableException,
+                       ELException {
+               if (context == null) {
+                       throw new NullPointerException();
+               }
+
+               if (base == null) {
+                       context.setPropertyResolved(true);
+                       throw new PropertyNotWritableException(
+                                       "Legacy VariableResolver wrapped, not 
writable");
+               }
+
+               if (!context.isPropertyResolved()) {
+                       DefaultResolver.setValue(context, base, property, 
value);
+               }
+       }
+
+       public boolean isReadOnly(ELContext context, Object base, Object 
property)
+                       throws NullPointerException, PropertyNotFoundException, 
ELException {
+               if (context == null) {
+                       throw new NullPointerException();
+               }
+
+               if (base == null) {
+                       context.setPropertyResolved(true);
+                       return true;
+               }
+
+               return DefaultResolver.isReadOnly(context, base, property);
+       }
+
+       public Iterator getFeatureDescriptors(ELContext context, Object base) {
+               return DefaultResolver.getFeatureDescriptors(context, base);
+       }
+
+       public Class<?> getCommonPropertyType(ELContext context, Object base) {
+               if (base == null) {
+                       return String.class;
+               }
+               return DefaultResolver.getCommonPropertyType(context, base);
+       }
+
+}

Added: 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ExpressionEvaluatorImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ExpressionEvaluatorImpl.java?rev=379417&view=auto
==============================================================================
--- 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ExpressionEvaluatorImpl.java
 (added)
+++ 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ExpressionEvaluatorImpl.java
 Tue Feb 21 02:57:35 2006
@@ -0,0 +1,42 @@
+package org.apache.jasper.el;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.servlet.jsp.el.ELException;
+import javax.servlet.jsp.el.ELParseException;
+import javax.servlet.jsp.el.Expression;
+import javax.servlet.jsp.el.ExpressionEvaluator;
+import javax.servlet.jsp.el.FunctionMapper;
+import javax.servlet.jsp.el.VariableResolver;
+
+
+public class ExpressionEvaluatorImpl extends ExpressionEvaluator {
+
+       private final ExpressionFactory factory;
+       
+       public ExpressionEvaluatorImpl(ExpressionFactory factory) {
+               this.factory = factory;
+       }
+
+       public Expression parseExpression(String expression, Class expectedType,
+                       FunctionMapper fMapper) throws ELException {
+               try {
+                       ELContextImpl ctx = new 
ELContextImpl(ELResolverImpl.DefaultResolver);
+            if (fMapper != null) {
+                ctx.setFunctionMapper(new FunctionMapperImpl(fMapper));
+            }
+                       ValueExpression ve = 
this.factory.createValueExpression(ctx, expression, expectedType);
+                       return new ExpressionImpl(ve);
+               } catch (javax.el.ELException e) {
+                       throw new ELParseException(e.getMessage());
+               }
+       }
+
+       public Object evaluate(String expression, Class expectedType,
+                       VariableResolver vResolver, FunctionMapper fMapper)
+                       throws ELException {
+               return this.parseExpression(expression, expectedType, 
fMapper).evaluate(vResolver);
+       }
+
+}

Added: tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ExpressionImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ExpressionImpl.java?rev=379417&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ExpressionImpl.java 
(added)
+++ tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/ExpressionImpl.java 
Tue Feb 21 02:57:35 2006
@@ -0,0 +1,26 @@
+package org.apache.jasper.el;
+
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.ValueExpression;
+import javax.servlet.jsp.el.ELException;
+import javax.servlet.jsp.el.Expression;
+import javax.servlet.jsp.el.VariableResolver;
+
+import org.apache.jasper.runtime.JspApplicationContextImpl;
+
+public class ExpressionImpl extends Expression {
+
+       private final ValueExpression ve;
+       
+       public ExpressionImpl(ValueExpression ve) {
+               this.ve = ve;
+       }
+
+       public Object evaluate(VariableResolver vResolver) throws ELException {
+               ELContext ctx = new ELContextImpl(new 
ELResolverImpl(vResolver));
+               return ve.getValue(ctx);
+       }
+
+}

Added: 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/FunctionMapperImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/FunctionMapperImpl.java?rev=379417&view=auto
==============================================================================
--- 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/FunctionMapperImpl.java 
(added)
+++ 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/FunctionMapperImpl.java 
Tue Feb 21 02:57:35 2006
@@ -0,0 +1,19 @@
+package org.apache.jasper.el;
+
+import java.lang.reflect.Method;
+
+import javax.servlet.jsp.el.FunctionMapper;
+
+public class FunctionMapperImpl extends javax.el.FunctionMapper {
+       
+       private final FunctionMapper fnMapper;
+
+       public FunctionMapperImpl(FunctionMapper fnMapper) {
+               this.fnMapper = fnMapper;
+       }
+
+       public Method resolveFunction(String prefix, String localName) {
+               return this.fnMapper.resolveFunction(prefix, localName);
+       }
+
+}

Added: 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/VariableResolverImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/VariableResolverImpl.java?rev=379417&view=auto
==============================================================================
--- 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/VariableResolverImpl.java 
(added)
+++ 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/el/VariableResolverImpl.java 
Tue Feb 21 02:57:35 2006
@@ -0,0 +1,19 @@
+package org.apache.jasper.el;
+
+import javax.el.ELContext;
+import javax.servlet.jsp.el.ELException;
+import javax.servlet.jsp.el.VariableResolver;
+
+public class VariableResolverImpl implements VariableResolver {
+
+       private final ELContext ctx;
+       
+       public VariableResolverImpl(ELContext ctx) {
+               this.ctx = ctx;
+       }
+
+       public Object resolveVariable(String pName) throws ELException {
+               return this.ctx.getELResolver().getValue(this.ctx, pName, null);
+       }
+
+}

Modified: 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/resources/LocalStrings.properties
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/resources/LocalStrings.properties?rev=379417&r1=379416&r2=379417&view=diff
==============================================================================
--- 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/resources/LocalStrings.properties
 (original)
+++ 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/resources/LocalStrings.properties
 Tue Feb 21 02:57:35 2006
@@ -408,3 +408,16 @@
 jsp.error.unbalanced.endtag=The end tag \"&lt;/{0}\" is unbalanced
 jsp.error.invalid.bean=The value for the useBean class attribute {0} is 
invalid.
 jsp.error.prefix.use_before_dcl=The prefix {0} specified in this tag directive 
has been previously used by an action in file {1} line {2}.
+
+# JSP 2.1
+jsp.error.el.template.deferred=#{..} is not allowed in template text
+jsp.error.el.parse={0} : {1}
+jsp.error.page.invalid.deferredsyntaxallowedasliteral=Page directive: invalid 
value for deferredSyntaxAllowedAsLiteral
+jsp.error.tag.invalid.deferredsyntaxallowedasliteral=Tag directive: invalid 
value for deferredSyntaxAllowedAsLiteral
+jsp.error.page.conflict.deferredsyntaxallowedasliteral=Page directive: illegal 
to have multiple occurrences of 'deferredSyntaxAllowedAsLiteral' with different 
values (old: {0}, new: {1})
+jsp.error.tag.conflict.deferredsyntaxallowedasliteral=Tag directive: illegal 
to have multiple occurrences of 'deferredSyntaxAllowedAsLiteral' with different 
values (old: {0}, new: {1})
+
+jsp.error.page.invalid.trimdirectivewhitespaces=Page directive: invalid value 
for trimDirectiveWhitespaces
+jsp.error.tag.invalid.trimdirectivewhitespaces=Tag directive: invalid value 
for trimDirectiveWhitespaces
+jsp.error.page.conflict.trimdirectivewhitespaces=Page directive: illegal to 
have multiple occurrences of 'trimDirectiveWhitespaces' with different values 
(old: {0}, new: {1})
+jsp.error.tag.conflict.trimdirectivewhitespaces=Tag directive: illegal to have 
multiple occurrences of 'trimDirectiveWhitespaces' with different values (old: 
{0}, new: {1})
\ No newline at end of file

Added: 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspApplicationContextImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspApplicationContextImpl.java?rev=379417&view=auto
==============================================================================
--- 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspApplicationContextImpl.java
 (added)
+++ 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspApplicationContextImpl.java
 Tue Feb 21 02:57:35 2006
@@ -0,0 +1,140 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jasper.runtime;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.el.ArrayELResolver;
+import javax.el.BeanELResolver;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELContextEvent;
+import javax.el.ELContextListener;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.el.ResourceBundleELResolver;
+import javax.servlet.ServletContext;
+import javax.servlet.jsp.JspApplicationContext;
+import javax.servlet.jsp.JspContext;
+import javax.servlet.jsp.el.ImplicitObjectELResolver;
+import javax.servlet.jsp.el.ScopedAttributeELResolver;
+import javax.servlet.jsp.el.VariableResolver;
+
+import org.apache.el.ExpressionFactoryImpl;
+import org.apache.jasper.el.ELContextImpl;
+import org.apache.jasper.el.ELResolverImpl;
+
+/**
+ * Implementation of JspApplicationContext
+ * 
+ * @author Jacob Hookom
+ */
+public class JspApplicationContextImpl implements JspApplicationContext {
+
+       private final static String KEY = JspApplicationContext.class.getName();
+
+       private final static ExpressionFactory expressionFactory = new 
ExpressionFactoryImpl();
+
+       private final List<ELContextListener> contextListeners = new 
ArrayList<ELContextListener>();
+
+       private final List<ELResolver> resolvers = new ArrayList<ELResolver>();
+
+       private boolean instantiated = false;
+
+       private ELResolver resolver;
+
+       public JspApplicationContextImpl() {
+
+       }
+
+       public void addELContextListener(ELContextListener listener) {
+               if (listener == null) {
+                       throw new IllegalArgumentException("ELConextListener 
was null");
+               }
+               this.contextListeners.add(listener);
+       }
+
+       public static JspApplicationContextImpl getInstance(ServletContext 
context) {
+               if (context == null) {
+                       throw new IllegalArgumentException("ServletContext was 
null");
+               }
+               JspApplicationContextImpl impl = (JspApplicationContextImpl) 
context
+                               .getAttribute(KEY);
+               if (impl == null) {
+                       impl = new JspApplicationContextImpl();
+                       context.setAttribute(KEY, impl);
+               }
+               return impl;
+       }
+
+       public ELContextImpl createELContext(JspContext context) {
+               if (context == null) {
+                       throw new IllegalArgumentException("JspContext was 
null");
+               }
+
+               // create ELContext for JspContext
+               ELResolver r = this.createELResolver();
+               ELContextImpl ctx = new ELContextImpl(r);
+               ctx.putContext(JspContext.class, context);
+
+               // alert all ELContextListeners
+               ELContextEvent event = new ELContextEvent(ctx);
+               for (int i = 0; i < this.contextListeners.size(); i++) {
+                       this.contextListeners.get(i).contextCreated(event);
+               }
+
+               return ctx;
+       }
+
+       private ELResolver createELResolver() {
+               this.instantiated = true;
+               if (this.resolver == null) {
+                       CompositeELResolver r = new CompositeELResolver();
+                       r.add(new ImplicitObjectELResolver());
+                       for (Iterator itr = this.resolvers.iterator(); 
itr.hasNext();) {
+                               r.add((ELResolver) itr.next());
+                       }
+                       r.add(new MapELResolver());
+                       r.add(new ResourceBundleELResolver());
+                       r.add(new ListELResolver());
+                       r.add(new ArrayELResolver());   
+                       r.add(new BeanELResolver());
+                       r.add(new ScopedAttributeELResolver());
+                       this.resolver = r;
+               }
+               return this.resolver;
+       }
+
+       public void addELResolver(ELResolver resolver) throws 
IllegalStateException {
+               if (resolver == null) {
+                       throw new IllegalArgumentException("ELResolver was 
null");
+               }
+               if (this.instantiated) {
+                       throw new IllegalStateException(
+                                       "cannot call addELResolver after the 
first request has been made");
+               }
+               this.resolvers.add(resolver);
+       }
+
+       public ExpressionFactory getExpressionFactory() {
+               return expressionFactory;
+       }
+
+}

Modified: 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspContextWrapper.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspContextWrapper.java?rev=379417&r1=379416&r2=379417&view=diff
==============================================================================
--- 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspContextWrapper.java
 (original)
+++ 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspContextWrapper.java
 Tue Feb 21 02:57:35 2006
@@ -24,6 +24,7 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.el.ELContext;
 import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
@@ -32,6 +33,7 @@
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.servlet.jsp.JspContext;
+import javax.servlet.jsp.JspFactory;
 import javax.servlet.jsp.JspWriter;
 import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.el.ELException;
@@ -40,415 +42,415 @@
 import javax.servlet.jsp.tagext.BodyContent;
 import javax.servlet.jsp.tagext.VariableInfo;
 
-import org.apache.commons.el.VariableResolverImpl;
 import org.apache.jasper.compiler.Localizer;
+import org.apache.jasper.el.ELContextImpl;
 
 /**
  * Implementation of a JSP Context Wrapper.
- *
+ * 
  * The JSP Context Wrapper is a JspContext created and maintained by a tag
  * handler implementation. It wraps the Invoking JSP Context, that is, the
  * JspContext instance passed to the tag handler by the invoking page via
  * setJspContext().
- *
+ * 
  * @author Kin-man Chung
  * @author Jan Luehe
+ * @author Jacob Hookom
  */
-public class JspContextWrapper
-            extends PageContext implements VariableResolver {
+public class JspContextWrapper extends PageContext implements VariableResolver 
{
 
-    // Invoking JSP context
-    private PageContext invokingJspCtxt;
+       // Invoking JSP context
+       private PageContext invokingJspCtxt;
 
-    private transient Hashtable        pageAttributes;
+       private transient Hashtable pageAttributes;
 
-    // ArrayList of NESTED scripting variables
-    private ArrayList nestedVars;
+       // ArrayList of NESTED scripting variables
+       private ArrayList nestedVars;
 
-    // ArrayList of AT_BEGIN scripting variables
-    private ArrayList atBeginVars;
+       // ArrayList of AT_BEGIN scripting variables
+       private ArrayList atBeginVars;
 
-    // ArrayList of AT_END scripting variables
-    private ArrayList atEndVars;
+       // ArrayList of AT_END scripting variables
+       private ArrayList atEndVars;
 
-    private Map aliases;
+       private Map aliases;
 
-    private Hashtable originalNestedVars;
+       private Hashtable originalNestedVars;
 
-    /**
-     * The variable resolver, for evaluating EL expressions.
-     */
-    private VariableResolverImpl variableResolver
-        = new VariableResolverImpl(this);
+       public JspContextWrapper(JspContext jspContext, ArrayList nestedVars,
+                       ArrayList atBeginVars, ArrayList atEndVars, Map 
aliases) {
+               this.invokingJspCtxt = (PageContext) jspContext;
+               this.nestedVars = nestedVars;
+               this.atBeginVars = atBeginVars;
+               this.atEndVars = atEndVars;
+               this.pageAttributes = new Hashtable(16);
+               this.aliases = aliases;
 
-    public JspContextWrapper(JspContext jspContext, ArrayList nestedVars,
-                            ArrayList atBeginVars, ArrayList atEndVars,
-                            Map aliases) {
-        this.invokingJspCtxt = (PageContext) jspContext;
-       this.nestedVars = nestedVars;
-       this.atBeginVars = atBeginVars;
-       this.atEndVars = atEndVars;
-       this.pageAttributes = new Hashtable(16);
-       this.aliases = aliases;
+               if (nestedVars != null) {
+                       this.originalNestedVars = new 
Hashtable(nestedVars.size());
+               }
+               syncBeginTagFile();
+       }
 
-       if (nestedVars != null) {
-           this.originalNestedVars = new Hashtable(nestedVars.size());
+       public void initialize(Servlet servlet, ServletRequest request,
+                       ServletResponse response, String errorPageURL,
+                       boolean needsSession, int bufferSize, boolean autoFlush)
+                       throws IOException, IllegalStateException, 
IllegalArgumentException {
        }
-       syncBeginTagFile();
-    }
 
-    public void initialize(Servlet servlet, ServletRequest request,
-                           ServletResponse response, String errorPageURL,
-                           boolean needsSession, int bufferSize,
-                           boolean autoFlush)
-        throws IOException, IllegalStateException, IllegalArgumentException
-    {
-    }
-    
-    public Object getAttribute(String name) {
+       public Object getAttribute(String name) {
+
+               if (name == null) {
+                       throw new NullPointerException(Localizer
+                                       
.getMessage("jsp.error.attribute.null_name"));
+               }
 
-       if (name == null) {
-           throw new NullPointerException(
-                   Localizer.getMessage("jsp.error.attribute.null_name"));
+               return pageAttributes.get(name);
        }
 
-       return pageAttributes.get(name);
-    }
+       public Object getAttribute(String name, int scope) {
 
-    public Object getAttribute(String name, int scope) {
+               if (name == null) {
+                       throw new NullPointerException(Localizer
+                                       
.getMessage("jsp.error.attribute.null_name"));
+               }
 
-       if (name == null) {
-           throw new NullPointerException(
-                   Localizer.getMessage("jsp.error.attribute.null_name"));
-       }
+               if (scope == PAGE_SCOPE) {
+                       return pageAttributes.get(name);
+               }
 
-       if (scope == PAGE_SCOPE) {
-           return pageAttributes.get(name);
+               return invokingJspCtxt.getAttribute(name, scope);
        }
 
-       return invokingJspCtxt.getAttribute(name, scope);
-    }
+       public void setAttribute(String name, Object value) {
 
-    public void setAttribute(String name, Object value) {
+               if (name == null) {
+                       throw new NullPointerException(Localizer
+                                       
.getMessage("jsp.error.attribute.null_name"));
+               }
 
-       if (name == null) {
-           throw new NullPointerException(
-                   Localizer.getMessage("jsp.error.attribute.null_name"));
+               if (value != null) {
+                       pageAttributes.put(name, value);
+               } else {
+                       removeAttribute(name, PAGE_SCOPE);
+               }
        }
 
-       if (value != null) {
-           pageAttributes.put(name, value);
-       } else {
-           removeAttribute(name, PAGE_SCOPE);
+       public void setAttribute(String name, Object value, int scope) {
+
+               if (name == null) {
+                       throw new NullPointerException(Localizer
+                                       
.getMessage("jsp.error.attribute.null_name"));
+               }
+
+               if (scope == PAGE_SCOPE) {
+                       if (value != null) {
+                               pageAttributes.put(name, value);
+                       } else {
+                               removeAttribute(name, PAGE_SCOPE);
+                       }
+               } else {
+                       invokingJspCtxt.setAttribute(name, value, scope);
+               }
        }
-    }
 
-    public void setAttribute(String name, Object value, int scope) {
+       public Object findAttribute(String name) {
+
+               if (name == null) {
+                       throw new NullPointerException(Localizer
+                                       
.getMessage("jsp.error.attribute.null_name"));
+               }
+
+               Object o = pageAttributes.get(name);
+               if (o == null) {
+                       o = invokingJspCtxt.getAttribute(name, REQUEST_SCOPE);
+                       if (o == null) {
+                               if (getSession() != null) {
+                                       o = invokingJspCtxt.getAttribute(name, 
SESSION_SCOPE);
+                               }
+                               if (o == null) {
+                                       o = invokingJspCtxt.getAttribute(name, 
APPLICATION_SCOPE);
+                               }
+                       }
+               }
 
-       if (name == null) {
-           throw new NullPointerException(
-                   Localizer.getMessage("jsp.error.attribute.null_name"));
+               return o;
        }
 
-       if (scope == PAGE_SCOPE) {
-           if (value != null) {
-               pageAttributes.put(name, value);
-           } else {
-               removeAttribute(name, PAGE_SCOPE);
-           }
-       } else {
-           invokingJspCtxt.setAttribute(name, value, scope);
+       public void removeAttribute(String name) {
+
+               if (name == null) {
+                       throw new NullPointerException(Localizer
+                                       
.getMessage("jsp.error.attribute.null_name"));
+               }
+
+               pageAttributes.remove(name);
+               invokingJspCtxt.removeAttribute(name, REQUEST_SCOPE);
+               if (getSession() != null) {
+                       invokingJspCtxt.removeAttribute(name, SESSION_SCOPE);
+               }
+               invokingJspCtxt.removeAttribute(name, APPLICATION_SCOPE);
        }
-    }
 
-    public Object findAttribute(String name) {
+       public void removeAttribute(String name, int scope) {
 
-       if (name == null) {
-           throw new NullPointerException(
-                   Localizer.getMessage("jsp.error.attribute.null_name"));
+               if (name == null) {
+                       throw new NullPointerException(Localizer
+                                       
.getMessage("jsp.error.attribute.null_name"));
+               }
+
+               if (scope == PAGE_SCOPE) {
+                       pageAttributes.remove(name);
+               } else {
+                       invokingJspCtxt.removeAttribute(name, scope);
+               }
        }
 
-        Object o = pageAttributes.get(name);
-        if (o == null) {
-           o = invokingJspCtxt.getAttribute(name, REQUEST_SCOPE);
-           if (o == null) {
-               if (getSession() != null) {
-                   o = invokingJspCtxt.getAttribute(name, SESSION_SCOPE);
+       public int getAttributesScope(String name) {
+
+               if (name == null) {
+                       throw new NullPointerException(Localizer
+                                       
.getMessage("jsp.error.attribute.null_name"));
                }
-               if (o == null) {
-                   o = invokingJspCtxt.getAttribute(name, APPLICATION_SCOPE);
-               } 
-           }
-       }
-
-       return o;
-    }
-
-    public void removeAttribute(String name) {
-
-       if (name == null) {
-           throw new NullPointerException(
-                   Localizer.getMessage("jsp.error.attribute.null_name"));
-       }
-
-       pageAttributes.remove(name);
-       invokingJspCtxt.removeAttribute(name, REQUEST_SCOPE);
-       if (getSession() != null) {
-           invokingJspCtxt.removeAttribute(name, SESSION_SCOPE);
-       }
-       invokingJspCtxt.removeAttribute(name, APPLICATION_SCOPE);
-    }
-
-    public void removeAttribute(String name, int scope) {
-
-       if (name == null) {
-           throw new NullPointerException(
-                   Localizer.getMessage("jsp.error.attribute.null_name"));
-       }
-
-       if (scope == PAGE_SCOPE){
-           pageAttributes.remove(name);
-       } else {
-           invokingJspCtxt.removeAttribute(name, scope);
-       }
-    }
-
-    public int getAttributesScope(String name) {
-
-       if (name == null) {
-           throw new NullPointerException(
-                   Localizer.getMessage("jsp.error.attribute.null_name"));
-       }
-
-       if (pageAttributes.get(name) != null) {
-           return PAGE_SCOPE;
-       } else {
-           return invokingJspCtxt.getAttributesScope(name);
-       }
-    }
-
-    public Enumeration getAttributeNamesInScope(int scope) {
-        if (scope == PAGE_SCOPE) {
-            return pageAttributes.keys();
-       }
-
-       return invokingJspCtxt.getAttributeNamesInScope(scope);
-    }
-
-    public void release() {
-       invokingJspCtxt.release();
-    }
-
-    public JspWriter getOut() {
-       return invokingJspCtxt.getOut();
-    }
-
-    public HttpSession getSession() {
-       return invokingJspCtxt.getSession();
-    }
-
-    public Object getPage() {
-       return invokingJspCtxt.getPage();
-    }
-
-    public ServletRequest getRequest() {
-       return invokingJspCtxt.getRequest();
-    }
-
-    public ServletResponse getResponse() {
-       return invokingJspCtxt.getResponse();
-    }
-
-    public Exception getException() {
-       return invokingJspCtxt.getException();
-    }
-
-    public ServletConfig getServletConfig() {
-       return invokingJspCtxt.getServletConfig();
-    }
-
-    public ServletContext getServletContext() {
-       return invokingJspCtxt.getServletContext();
-    }
-
-    public void forward(String relativeUrlPath)
-        throws ServletException, IOException
-    {
-       invokingJspCtxt.forward(relativeUrlPath);
-    }
-
-    public void include(String relativeUrlPath)
-       throws ServletException, IOException
-    {
-       invokingJspCtxt.include(relativeUrlPath);
-    }
-
-    public void include(String relativeUrlPath, boolean flush) 
-           throws ServletException, IOException {
-       include(relativeUrlPath, false); // XXX
-    }
-
-    public VariableResolver getVariableResolver() {
-       return this;
-    }
-
-    public BodyContent pushBody() {
-       return invokingJspCtxt.pushBody();
-    }
-
-    public JspWriter pushBody(Writer writer) {
-       return invokingJspCtxt.pushBody(writer);
-    }
-
-    public JspWriter popBody() {
-        return invokingJspCtxt.popBody();
-    }
-
-    public ExpressionEvaluator getExpressionEvaluator() {
-       return invokingJspCtxt.getExpressionEvaluator();
-    }
-
-    public void handlePageException(Exception ex)
-        throws IOException, ServletException 
-    {
-       // Should never be called since handleException() called with a
-       // Throwable in the generated servlet.
-       handlePageException((Throwable) ex);
-    }
-
-    public void handlePageException(Throwable t)
-        throws IOException, ServletException 
-    {
-       invokingJspCtxt.handlePageException(t);
-    }
-
-    /**
-     * VariableResolver interface
-     */
-    public Object resolveVariable( String pName ) throws ELException
-    {
-        return variableResolver.resolveVariable(pName);
-    }
-
-    /**
-     * Synchronize variables at begin of tag file
-     */
-    public void syncBeginTagFile() {
-       saveNestedVariables();
-    }
-
-    /**
-     * Synchronize variables before fragment invokation
-     */
-    public void syncBeforeInvoke() {
-       copyTagToPageScope(VariableInfo.NESTED);
-       copyTagToPageScope(VariableInfo.AT_BEGIN);
-    }
-
-    /**
-     * Synchronize variables at end of tag file
-     */
-    public void syncEndTagFile() {
-       copyTagToPageScope(VariableInfo.AT_BEGIN);
-       copyTagToPageScope(VariableInfo.AT_END);
-       restoreNestedVariables();
-    }
-
-    /**
-     * Copies the variables of the given scope from the virtual page scope of
-     * this JSP context wrapper to the page scope of the invoking JSP context.
-     *
-     * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
-     */
-    private void copyTagToPageScope(int scope) {
-       Iterator iter = null;
-
-       switch (scope) {
-       case VariableInfo.NESTED:
-           if (nestedVars != null) {
-               iter = nestedVars.iterator();
-           }
-           break;
-       case VariableInfo.AT_BEGIN:
-           if (atBeginVars != null) {
-               iter = atBeginVars.iterator();
-           }
-           break;
-       case VariableInfo.AT_END:
-           if (atEndVars != null) {
-               iter = atEndVars.iterator();
-           }
-           break;
-       }
-
-       while ((iter != null) && iter.hasNext()) {
-           String varName = (String) iter.next();
-           Object obj = getAttribute(varName);
-           varName = findAlias(varName);
-           if (obj != null) {
-               invokingJspCtxt.setAttribute(varName, obj);
-           } else {
-               invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
-           }
-       }
-    }
-
-    /**
-     * Saves the values of any NESTED variables that are present in
-     * the invoking JSP context, so they can later be restored.
-     */
-    private void saveNestedVariables() {
-       if (nestedVars != null) {
-           Iterator iter = nestedVars.iterator();
-           while (iter.hasNext()) {
-               String varName = (String) iter.next();
-               varName = findAlias(varName);
-               Object obj = invokingJspCtxt.getAttribute(varName);
-               if (obj != null) {
-                   originalNestedVars.put(varName, obj);
-               }
-           }
-       }
-    }
-
-    /**
-     * Restores the values of any NESTED variables in the invoking JSP
-     * context.
-     */
-    private void restoreNestedVariables() {
-       if (nestedVars != null) {
-           Iterator iter = nestedVars.iterator();
-           while (iter.hasNext()) {
-               String varName = (String) iter.next();
-               varName = findAlias(varName);
-               Object obj = originalNestedVars.get(varName);
-               if (obj != null) {
-                   invokingJspCtxt.setAttribute(varName, obj);
+
+               if (pageAttributes.get(name) != null) {
+                       return PAGE_SCOPE;
                } else {
-                   invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
+                       return invokingJspCtxt.getAttributesScope(name);
                }
-           }
        }
-    }
 
-    /**
-     * Checks to see if the given variable name is used as an alias, and if so,
-     * returns the variable name for which it is used as an alias.
-     *
-     * @param varName The variable name to check
-     * @return The variable name for which varName is used as an alias, or
-     * varName if it is not being used as an alias
-     */
-    private String findAlias(String varName) {
-
-       if (aliases == null)
-           return varName;
-
-       String alias = (String) aliases.get(varName);
-       if (alias == null) {
-           return varName;
+       public Enumeration getAttributeNamesInScope(int scope) {
+               if (scope == PAGE_SCOPE) {
+                       return pageAttributes.keys();
+               }
+
+               return invokingJspCtxt.getAttributeNamesInScope(scope);
        }
-       return alias;
-    }
-}
 
+       public void release() {
+               invokingJspCtxt.release();
+       }
+
+       public JspWriter getOut() {
+               return invokingJspCtxt.getOut();
+       }
+
+       public HttpSession getSession() {
+               return invokingJspCtxt.getSession();
+       }
+
+       public Object getPage() {
+               return invokingJspCtxt.getPage();
+       }
+
+       public ServletRequest getRequest() {
+               return invokingJspCtxt.getRequest();
+       }
+
+       public ServletResponse getResponse() {
+               return invokingJspCtxt.getResponse();
+       }
+
+       public Exception getException() {
+               return invokingJspCtxt.getException();
+       }
+
+       public ServletConfig getServletConfig() {
+               return invokingJspCtxt.getServletConfig();
+       }
+
+       public ServletContext getServletContext() {
+               return invokingJspCtxt.getServletContext();
+       }
+
+       public void forward(String relativeUrlPath) throws ServletException,
+                       IOException {
+               invokingJspCtxt.forward(relativeUrlPath);
+       }
+
+       public void include(String relativeUrlPath) throws ServletException,
+                       IOException {
+               invokingJspCtxt.include(relativeUrlPath);
+       }
+
+       public void include(String relativeUrlPath, boolean flush)
+                       throws ServletException, IOException {
+               include(relativeUrlPath, false); // XXX
+       }
+
+       public VariableResolver getVariableResolver() {
+               return this;
+       }
+
+       public BodyContent pushBody() {
+               return invokingJspCtxt.pushBody();
+       }
+
+       public JspWriter pushBody(Writer writer) {
+               return invokingJspCtxt.pushBody(writer);
+       }
+
+       public JspWriter popBody() {
+               return invokingJspCtxt.popBody();
+       }
+
+       public ExpressionEvaluator getExpressionEvaluator() {
+               return invokingJspCtxt.getExpressionEvaluator();
+       }
+
+       public void handlePageException(Exception ex) throws IOException,
+                       ServletException {
+               // Should never be called since handleException() called with a
+               // Throwable in the generated servlet.
+               handlePageException((Throwable) ex);
+       }
+
+       public void handlePageException(Throwable t) throws IOException,
+                       ServletException {
+               invokingJspCtxt.handlePageException(t);
+       }
+
+       /**
+        * VariableResolver interface
+        */
+       public Object resolveVariable(String pName) throws ELException {
+               ELContext ctx = this.getELContext();
+               return ctx.getELResolver().getValue(ctx, null, pName);
+       }
+
+       /**
+        * Synchronize variables at begin of tag file
+        */
+       public void syncBeginTagFile() {
+               saveNestedVariables();
+       }
+
+       /**
+        * Synchronize variables before fragment invokation
+        */
+       public void syncBeforeInvoke() {
+               copyTagToPageScope(VariableInfo.NESTED);
+               copyTagToPageScope(VariableInfo.AT_BEGIN);
+       }
+
+       /**
+        * Synchronize variables at end of tag file
+        */
+       public void syncEndTagFile() {
+               copyTagToPageScope(VariableInfo.AT_BEGIN);
+               copyTagToPageScope(VariableInfo.AT_END);
+               restoreNestedVariables();
+       }
+
+       /**
+        * Copies the variables of the given scope from the virtual page scope 
of
+        * this JSP context wrapper to the page scope of the invoking JSP 
context.
+        * 
+        * @param scope
+        *            variable scope (one of NESTED, AT_BEGIN, or AT_END)
+        */
+       private void copyTagToPageScope(int scope) {
+               Iterator iter = null;
+
+               switch (scope) {
+               case VariableInfo.NESTED:
+                       if (nestedVars != null) {
+                               iter = nestedVars.iterator();
+                       }
+                       break;
+               case VariableInfo.AT_BEGIN:
+                       if (atBeginVars != null) {
+                               iter = atBeginVars.iterator();
+                       }
+                       break;
+               case VariableInfo.AT_END:
+                       if (atEndVars != null) {
+                               iter = atEndVars.iterator();
+                       }
+                       break;
+               }
+
+               while ((iter != null) && iter.hasNext()) {
+                       String varName = (String) iter.next();
+                       Object obj = getAttribute(varName);
+                       varName = findAlias(varName);
+                       if (obj != null) {
+                               invokingJspCtxt.setAttribute(varName, obj);
+                       } else {
+                               invokingJspCtxt.removeAttribute(varName, 
PAGE_SCOPE);
+                       }
+               }
+       }
+
+       /**
+        * Saves the values of any NESTED variables that are present in the 
invoking
+        * JSP context, so they can later be restored.
+        */
+       private void saveNestedVariables() {
+               if (nestedVars != null) {
+                       Iterator iter = nestedVars.iterator();
+                       while (iter.hasNext()) {
+                               String varName = (String) iter.next();
+                               varName = findAlias(varName);
+                               Object obj = 
invokingJspCtxt.getAttribute(varName);
+                               if (obj != null) {
+                                       originalNestedVars.put(varName, obj);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Restores the values of any NESTED variables in the invoking JSP 
context.
+        */
+       private void restoreNestedVariables() {
+               if (nestedVars != null) {
+                       Iterator iter = nestedVars.iterator();
+                       while (iter.hasNext()) {
+                               String varName = (String) iter.next();
+                               varName = findAlias(varName);
+                               Object obj = originalNestedVars.get(varName);
+                               if (obj != null) {
+                                       invokingJspCtxt.setAttribute(varName, 
obj);
+                               } else {
+                                       
invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Checks to see if the given variable name is used as an alias, and if 
so,
+        * returns the variable name for which it is used as an alias.
+        * 
+        * @param varName
+        *            The variable name to check
+        * @return The variable name for which varName is used as an alias, or
+        *         varName if it is not being used as an alias
+        */
+       private String findAlias(String varName) {
+
+               if (aliases == null)
+                       return varName;
+
+               String alias = (String) aliases.get(varName);
+               if (alias == null) {
+                       return varName;
+               }
+               return alias;
+       }
+
+       private ELContextImpl elContext;
+
+       public ELContext getELContext() {
+               if (this.elContext == null) {
+                       JspFactory jspFact = JspFactory.getDefaultFactory();
+                       ServletContext servletContext = 
this.getServletContext();
+                       JspApplicationContextImpl jspCtx = 
(JspApplicationContextImpl) jspFact
+                                       
.getJspApplicationContext(servletContext);
+                       this.elContext = jspCtx.createELContext(this);
+               }
+               return this.elContext;
+       }
+}

Modified: 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspFactoryImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspFactoryImpl.java?rev=379417&r1=379416&r2=379417&view=diff
==============================================================================
--- 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspFactoryImpl.java 
(original)
+++ 
tomcat/jasper/tc6.0.x/src/share/org/apache/jasper/runtime/JspFactoryImpl.java 
Tue Feb 21 02:57:35 2006
@@ -19,8 +19,10 @@
 import java.security.PrivilegedAction;
 
 import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspApplicationContext;
 import javax.servlet.jsp.JspFactory;
 import javax.servlet.jsp.JspEngineInfo;
 import javax.servlet.jsp.PageContext;
@@ -40,10 +42,9 @@
     private Log log = LogFactory.getLog(JspFactoryImpl.class);
 
     private static final String SPEC_VERSION = "2.0";
-    private static final boolean USE_POOL = 
-        
Boolean.valueOf(System.getProperty("org.apache.jasper.runtime.JspFactoryImpl.USE_POOL",
 "true")).booleanValue();
+    private static final boolean USE_POOL = true;
 
-    private SimplePool pool = new SimplePool(100);
+    private SimplePool pool = new SimplePool( 100 );
     
     public PageContext getPageContext(Servlet servlet,
                                      ServletRequest request,
@@ -52,6 +53,7 @@
                                       boolean needsSession,
                                      int bufferSize,
                                       boolean autoflush) {
+
        if( System.getSecurityManager() != null ) {
            PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
                (JspFactoryImpl)this, servlet, request, response, errorPageURL,
@@ -174,4 +176,15 @@
            return null;
         }
     }
+    
+    private final static String APP_CONTEXT_VARIABLE = 
JspApplicationContextImpl.class.getName();
+
+       public JspApplicationContext getJspApplicationContext(ServletContext 
context) {
+        JspApplicationContext appContext = (JspApplicationContext) 
context.getAttribute(APP_CONTEXT_VARIABLE);
+               if (appContext == null) {
+            appContext = new JspApplicationContextImpl();
+            context.setAttribute(APP_CONTEXT_VARIABLE, appContext);
+        }
+        return appContext;
+       }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to