kinman 2002/08/12 10:55:45 Modified: jasper2/src/share/org/apache/jasper/compiler Generator.java jasper2/src/share/org/apache/jasper/runtime JspFragmentHelper.java PageContextImpl.java Log: - Mods with spec api changes. - Fix problems when tag files needs page context. Revision Changes Path 1.65 +26 -21 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java Index: Generator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- Generator.java 8 Aug 2002 20:41:02 -0000 1.64 +++ Generator.java 12 Aug 2002 17:55:45 -0000 1.65 @@ -1001,7 +1001,11 @@ out.print( pageParam ); printParams(n, pageParam, page.isLiteral()); out.println(");"); - out.printil((methodNesting > 0)? "return true;": "return;"); + if (isTagFile) { + out.printil("throw new javax.servlet.jsp.SkipPageException();"); + } else { + out.printil((methodNesting > 0)? "return true;": "return;"); + } out.popIndent(); out.printil("}"); @@ -1445,7 +1449,6 @@ makeAttr("java_archive", archive); out.printil("out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3) + ");"); - out.printil("out.write(\"\\n\");"); /* * Generate a 'attr = "value"' for each <jsp:param> in plugin body @@ -1764,7 +1767,7 @@ // Store varReader in appropriate scope if (varReader != null) { String scopeName = n.getAttributeValue("scope"); - out.printin("getJspContext().setAttribute("); + out.printin("pageContext.setAttribute("); out.print(quote(varReader)); out.print(", new java.io.StringReader(sout.toString())"); if (scopeName != null) { @@ -1812,13 +1815,13 @@ String name = tagVars[i].getNameGiven(); if (name != null) { out.print(quote(name)); - out.print(", getJspContext().getAttribute("); + out.print(", pageContext.getAttribute("); out.print(quote(name)); out.println("));"); } else { String getter = toGetterMethod(tagVars[i].getNameFromAttribute()); out.print(getter); - out.print(", getJspContext().getAttribute("); + out.print(", pageContext.getAttribute("); out.print(getter); out.println("));"); } @@ -1837,7 +1840,7 @@ // Store varReader in appropriate scope if (varReader != null) { String scopeName = n.getAttributeValue("scope"); - out.printin("getJspContext().setAttribute("); + out.printin("pageContext.setAttribute("); out.print(quote(varReader)); out.print(", new java.io.StringReader(sout.toString())"); if (scopeName != null) { @@ -2797,6 +2800,15 @@ out.println(); } + // Generate imports + Iterator iter = pageInfo.getImports().iterator(); + while (iter.hasNext()) { + out.printin("import "); + out.print ((String)iter.next()); + out.println(";"); + } + out.println(); + // Generate class declaration out.printin("public class "); out.print(tagInfo.getTagName()); @@ -2820,6 +2832,7 @@ out.printil("public void doTag() throws javax.servlet.jsp.JspException {"); out.pushIndent(); + out.printil("PageContext pageContext = new JspContextWrapper(getJspContext());"); // Declare parameter map for fragment/body invocation out.printil("java.util.Map params = null;"); @@ -2827,8 +2840,7 @@ // if 'varReader' attribute is specified out.printil("java.io.Writer sout = null;"); - out.printil("javax.servlet.jsp.JspWriter out = getJspContext().getOut();"); - out.printil("getJspContext().pushPageScope(null);"); + out.printil("javax.servlet.jsp.JspWriter out = pageContext.getOut();"); generatePageScopedVariables(tagInfo); out.printil("try {"); out.pushIndent(); @@ -2840,10 +2852,6 @@ out.pushIndent(); out.printil("throw new javax.servlet.jsp.JspException(ioe);"); out.popIndent(); - out.printil("} finally {"); - out.pushIndent(); - out.printil("getJspContext().popPageScope();"); - out.popIndent(); out.printil("}"); out.popIndent(); out.printil("}"); @@ -2988,7 +2996,7 @@ if (attrInfos != null) { for (int i=0; i<attrInfos.length; i++) { String attrName = attrInfos[i].getName(); - out.printin("getJspContext().setAttribute("); + out.printin("pageContext.setAttribute("); out.print(quote(attrName)); out.print(", "); out.print(toGetterMethod(attrName)); @@ -3002,7 +3010,7 @@ if (fragAttrInfos != null) { for (int i=0; i<fragAttrInfos.length; i++) { String attrName = fragAttrInfos[i].getName(); - out.printin("getJspContext().setAttribute("); + out.printin("pageContext.setAttribute("); out.print(quote(attrName)); out.print(", "); out.print(toGetterMethod(attrName)); @@ -3015,7 +3023,7 @@ out.printil("for (java.util.Iterator i = dynamicAttrs.entrySet().iterator(); i.hasNext(); ) {"); out.pushIndent(); out.printil("java.util.Map.Entry e = (java.util.Map.Entry) i.next();"); - out.printil("getJspContext().setAttribute((String) e.getKey(), e.getValue());"); + out.printil("pageContext.setAttribute((String) e.getKey(), e.getValue());"); out.popIndent(); out.printil("}"); } @@ -3253,8 +3261,6 @@ out.popIndent(); out.printil( "{" ); out.pushIndent(); - out.printil( - "this.jspContext.pushPageScope( this.originalPageScope );" ); out.printil( "java.util.Map _jspx_originalValues = null;" ); out.printil( "if( params != null ) {" ); out.pushIndent(); @@ -3293,7 +3299,6 @@ out.printil( "restorePageScope( _jspx_originalValues );"); out.popIndent(); out.printil( "}" ); - out.printil( "this.jspContext.popPageScope();" ); out.popIndent(); out.printil( "}" ); // finally out.popIndent(); 1.3 +4 -6 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspFragmentHelper.java Index: JspFragmentHelper.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspFragmentHelper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JspFragmentHelper.java 5 Aug 2002 21:05:24 -0000 1.2 +++ JspFragmentHelper.java 12 Aug 2002 17:55:45 -0000 1.3 @@ -90,7 +90,6 @@ protected JspContext jspContext; protected PageContext pageContext; protected JspTag parentTag; - protected Map originalPageScope; public JspFragmentHelper( int discriminator, JspContext jspContext, JspTag parentTag ) @@ -102,7 +101,6 @@ pageContext = (PageContext)jspContext; } this.parentTag = parentTag; - this.originalPageScope = jspContext.peekPageScope(); } public JspContext getJspContext() { @@ -127,7 +125,7 @@ while( keys.hasNext() ) { String key = (String)keys.next(); // Remember original values to restore later - originalValues.put( key, originalPageScope.get( key ) ); + originalValues.put( key, jspContext.getAttribute( key ) ); // Set new values, based on params jspContext.setAttribute( key, params.get( key ) ); } 1.15 +3 -67 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java Index: PageContextImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- PageContextImpl.java 6 Aug 2002 05:33:30 -0000 1.14 +++ PageContextImpl.java 12 Aug 2002 17:55:45 -0000 1.15 @@ -465,67 +465,6 @@ } /** - * Pops the page scope from the stack. After calling this method, the - * PageScope will appear the same as it was before the last call to - * pushPageScope. - * - * @return A Map representing the state of the page scope just before - * it was popped. This object can be passed to pushPageScope to - * restore this state. The keys of the returned Map are Strings - * representing attribute names. The values are the values of - * those attributes. - */ - public java.util.Map popPageScope() - throws EmptyStackException - { - if( this.attributesStack == null ) { - throw new EmptyStackException(); - } - // Remember pop() may throw EmptyStackException. - this.attributes = (Hashtable)this.attributesStack.pop(); - return this.attributes; - } - - /** - * Pushes a new page scope on the stack. - * - * @param scopeState If null, a new, empty, page scope is pushed. - * Otherwise, the state of the page scope is restored to the - * contents of the provided Map. - */ - public void pushPageScope( java.util.Map scopeState ) { - // Lazily create page scope stack - if( this.attributesStack == null ) { - this.attributesStack = new Stack(); - } - - // Push the old page scope on the stack: - this.attributesStack.push( this.attributes ); - - // Set the new page scope, depending on the input. - if( scopeState == null ) { - // Create a fresh page scope: - this.attributes = new Hashtable( 16 ); - } - else if( scopeState instanceof Hashtable ) { - // Compatible Map. - this.attributes = (Hashtable)scopeState; - } - else { - // Incompatible Map. Only Maps returned by popPageScope() - // or peekPageScope() can be passed in to this method. - // Therefore, the scopeState MUST be an instance of Hashtable. - throw new IllegalArgumentException( - "Attempt to pass PageContext.pushPageScope() a Map " + - "that was not created by this container." ); - } - } - - public java.util.Map peekPageScope() { - return this.attributes; - } - - /** * Provides programmatic access to the ExpressionEvaluator. * The JSP Container must return a valid instance of an * ExpressionEvaluator that can parse EL expressions. @@ -612,9 +551,6 @@ protected transient Hashtable attributes = new Hashtable(16); - // Page scope attribute stack, to implement {push|pop|peek}PageScope: - // Lazily initialized. - protected transient Stack attributesStack = null; // per request state protected transient ServletRequest request;
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>