- Remove apparently useless fields from the page context.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 20 Sep 2006 01:15:32 +0000 (01:15 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 20 Sep 2006 01:15:32 +0000 (01:15 +0000)
- Attributes are now a HashMap, since the page context is a per request object.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@448022 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/runtime/JspFactoryImpl.java
java/org/apache/jasper/runtime/PageContextImpl.java

index 7408eb8..e1293b2 100644 (file)
@@ -95,17 +95,17 @@ public class JspFactoryImpl extends JspFactory {
                                               int bufferSize, 
                                               boolean autoflush) {
         try {
-           PageContext pc;
-           if( USE_POOL ) {
+            PageContext pc;
+            if( USE_POOL ) {
                 pc = (PageContext) pool.get();
-               if( pc == null ) {
-                   pc= new PageContextImpl(this);
-               }
-           } else {
-               pc = new PageContextImpl(this);
-           }
-           pc.initialize(servlet, request, response, errorPageURL, 
-                          needsSession, bufferSize, autoflush);
+                if( pc == null ) {
+                    pc = new PageContextImpl();
+                }
+            } else {
+                pc = new PageContextImpl();
+            }
+            pc.initialize(servlet, request, response, errorPageURL, 
+                    needsSession, bufferSize, autoflush);
             return pc;
         } catch (Throwable ex) {
             /* FIXME: need to do something reasonable here!! */
index 501efd8..6610da7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999,2004 The Apache Software Foundation.
+ * Copyright 1999,2004-2006 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.
@@ -23,10 +23,9 @@ import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
 
 import javax.el.ELContext;
-import javax.el.ELResolver;
 import javax.el.ExpressionFactory;
 import javax.el.ValueExpression;
 import javax.servlet.Servlet;
@@ -56,6 +55,7 @@ import org.apache.jasper.el.ExpressionEvaluatorImpl;
 import org.apache.jasper.el.FunctionMapperImpl;
 import org.apache.jasper.el.VariableResolverImpl;
 import org.apache.jasper.security.SecurityUtil;
+import org.apache.jasper.util.Enumerator;
 
 /**
  * Implementation of the PageContext class from the JSP spec. Also doubles as a
@@ -85,28 +85,18 @@ public class PageContextImpl extends PageContext {
 
        private ServletContext context;
 
-       private JspFactory factory;
-       
        private JspApplicationContextImpl applicationContext;
 
-       private boolean needsSession;
-
        private String errorPageURL;
 
-       private boolean autoFlush;
-
-       private int bufferSize;
-
        // page-scope attributes
-       private transient Hashtable attributes;
+       private transient HashMap<String, Object> attributes;
 
        // per-request state
        private transient ServletRequest request;
 
        private transient ServletResponse response;
 
-       private transient Object page;
-
        private transient HttpSession session;
        
        private transient ELContextImpl elContext;
@@ -114,8 +104,6 @@ public class PageContextImpl extends PageContext {
        private boolean isIncluded;
        
        
-       // 
-
        // initial output stream
        private transient JspWriter out;
 
@@ -124,10 +112,9 @@ public class PageContextImpl extends PageContext {
        /*
         * Constructor.
         */
-       PageContextImpl(JspFactory factory) {
-               this.factory = factory;
+       PageContextImpl() {
                this.outs = new BodyContentImpl[0];
-               this.attributes = new Hashtable(16);
+               this.attributes = new HashMap<String, Object>(16);
                this.depth = -1;
        }
 
@@ -149,10 +136,7 @@ public class PageContextImpl extends PageContext {
                this.servlet = servlet;
                this.config = servlet.getServletConfig();
                this.context = config.getServletContext();
-               this.needsSession = needsSession;
                this.errorPageURL = errorPageURL;
-               this.bufferSize = bufferSize;
-               this.autoFlush = autoFlush;
                this.request = request;
                this.response = response;
                
@@ -214,10 +198,7 @@ public class PageContextImpl extends PageContext {
                context = null;
         applicationContext = null;
         elContext = null;
-               needsSession = false;
                errorPageURL = null;
-               bufferSize = JspWriter.DEFAULT_BUFFER;
-               autoFlush = true;
                request = null;
                response = null;
                depth = -1;
@@ -509,7 +490,7 @@ public class PageContextImpl extends PageContext {
        private Enumeration doGetAttributeNamesInScope(int scope) {
                switch (scope) {
                case PAGE_SCOPE:
-                       return attributes.keys();
+                       return new Enumerator(attributes.keySet().iterator());
 
                case REQUEST_SCOPE:
                        return request.getAttributeNames();