[PATCH] jakarta-tomcat-jasper
Attached is a patch to bring Japser2 up to date with the latest APIs from the JSR-152 Expert Group. jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java - Updated to conform to new VariableResolver API jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java - Updated to conform to new VariableResolver API jasper2/src/share/org/apache/jasper/runtime/ExpressionEvaluatorImpl.java - Updated to conform to new VariableResolver API - Updated to conform to new ExpressionEvaluator API (which is now an abstract class instead of an interface) - Updated to conform to new Exrpression API (which is now an abstract class instead of an interface) --- Mark Roth, Java Software JSP 2.0 Co-Specification Lead Sun Microsystems, Inc. Index: jasper2/src/share/org/apache/jasper/runtime/ExpressionEvaluatorImpl.java === RCS file: /home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/ExpressionEvaluatorImpl.java,v retrieving revision 1.5 diff -u -r1.5 ExpressionEvaluatorImpl.java --- jasper2/src/share/org/apache/jasper/runtime/ExpressionEvaluatorImpl.java29 Aug 2002 02:04:21 - 1.5 +++ jasper2/src/share/org/apache/jasper/runtime/ExpressionEvaluatorImpl.java18 Dec +2002 02:37:36 - @@ -74,7 +74,7 @@ */ public class ExpressionEvaluatorImpl -implements ExpressionEvaluator +extends ExpressionEvaluator { private PageContextImpl pageContext; @@ -153,7 +153,7 @@ // pContext parameter is going away in JSP 2.0 Object result; try { -result = delegate.resolveVariable( pName, null ); +result = delegate.resolveVariable( pName ); } catch( ELException e ) { throw new org.apache.jasper.runtime.el.jstl.ELException( @@ -255,7 +255,7 @@ * can be moved out of JSTL into its own project. */ private class JSTLExpression -implements Expression +extends Expression { private String expression; private Class expectedType; Index: jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java === RCS file: /home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java,v retrieving revision 1.9 diff -u -r1.9 JspContextWrapper.java --- jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java 3 Dec 2002 23:17:48 - 1.9 +++ jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java 18 Dec 2002 +02:37:37 - @@ -303,16 +303,14 @@ /** * VariableResolver interface */ -public Object resolveVariable( String pName, Object pContext ) +public Object resolveVariable( String pName ) throws ELException { if (invokingJspCtxt instanceof PageContextImpl) { - return ((PageContextImpl) invokingJspCtxt).resolveVariable(pName, - pContext); + return ((PageContextImpl) invokingJspCtxt).resolveVariable(pName); } - return ((JspContextWrapper) invokingJspCtxt).resolveVariable(pName, -pContext); + return ((JspContextWrapper) invokingJspCtxt).resolveVariable(pName); } /** Index: jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java === RCS file: /home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java,v retrieving revision 1.37 diff -u -r1.37 PageContextImpl.java --- jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java3 Dec 2002 01:58:36 - 1.37 +++ jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java18 Dec 2002 +02:37:45 - @@ -640,13 +640,12 @@ /** * VariableResolver interface */ -public Object resolveVariable( String pName, Object pContext ) +public Object resolveVariable( String pName ) throws ELException { -// Note: pContext will be going away. try { -return PageContextImpl.variableResolver.resolveVariable( -pName, this ); +return PageContextImpl.variableResolver.resolveVariable( pName, +this ); } catch( org.apache.jasper.runtime.el.jstl.ELException e ) { throw new ELException( e ); -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
[PATCH] jakarta-tomcat-jasper (ImplicitTagLibraryInfo)
ImplicitTagLibraryInfo incorrectly returned null from getFunctions(). The spec requires a FunctionInfo[0] instead. Returning null also caused Generator.generateELFunctionMap to throw a NPE in some circumstances. Modified files: * jasper2/src/share/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java --- Mark Roth JSP 2.0 Specification Co-Lead Sun Microsystems, Inc. Index: jasper2/src/share/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java === RCS file: /home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java,v retrieving revision 1.15 diff -u -r1.15 ImplicitTagLibraryInfo.java --- jasper2/src/share/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java28 Nov 2002 04:18:08 - 1.15 +++ jasper2/src/share/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java13 Dec +2002 05:57:59 - @@ -61,6 +61,7 @@ package org.apache.jasper.compiler; import java.util.*; +import javax.servlet.jsp.tagext.FunctionInfo; import javax.servlet.jsp.tagext.TagLibraryInfo; import javax.servlet.jsp.tagext.TagInfo; import javax.servlet.jsp.tagext.TagFileInfo; @@ -100,6 +101,9 @@ this.pc = pc; this.tagFileMap = new Hashtable(); this.vec = new Vector(); + +// Implicit tag libraries have no functions: +this.functions = new FunctionInfo[0]; tlibversion = TLIB_VERSION; jspversion = JSP_VERSION; -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
[PATCH] jakarta-tomcat-jasper: Bugfix for 11883
Attached is a bugfix for bug 11883: Unable to use Dynamic attributes Files modified: jasper2/src/share/org/apache/jasper/compiler/Generator.java -- Mark Roth, Java Software Co-Specification Lead for JSP 2.0 Sun Microsystems, Inc. Index: jasper2/src/share/org/apache/jasper/compiler/Generator.java === RCS file: /home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v retrieving revision 1.74 diff -u -r1.74 Generator.java --- jasper2/src/share/org/apache/jasper/compiler/Generator.java 21 Aug 2002 16:21:56 - 1.74 +++ jasper2/src/share/org/apache/jasper/compiler/Generator.java 21 Aug 2002 17:14:54 - @@ -2459,9 +2459,15 @@ if (attrs[i].isDynamic()) { out.printin(tagHandlerVar); out.print(.); - out.print(setDynamicAttribute(\); - out.print(attrs[i].getURI()); - out.print(\, \); + out.print(setDynamicAttribute(); +String uri = attrs[i].getURI(); +if( .equals( uri ) || (uri == null) ) { +out.print( null ); +} +else { +out.print(\ + attrs[i].getURI() + \); +} + out.print(, \); out.print(attrs[i].getLocalName()); out.print(\, ); out.print(attrValue); -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
[PATCH] jakarta-tomcat-jasper: PFD features and bugfixes 3
Atached is a third patch to move us towards JSP 2.0 PFD feature-complete. More to come... File Changed (IN PATCH) jasper2/src/share/org/apache/jasper/compiler/Generator.java Summary of changes: - Removed TryCatchFinally handling for SimpleTag call generation. TryCatchFinally does not apply for SimpleTag anymore. - Fixed to only declare scripting variables for those variables whose declare attribute is set to 'true' (true by default). - Scripting variables were not being declared for SimpleTag calls. Fixed. - Fixed Tag Handler implementation to synchronize locally-scoped AT_BEGIN and AT_END variables with calling page's page context. Note that there are a number of spec bugs relating to synchronization that were discovered while implementing this. I'll take these findings to the Expert Group for further discussion. -- Mark Roth, Java Software JSP 2.0 Specification Co-Lead Sun Microsystems, Inc. Index: jasper2/src/share/org/apache/jasper/compiler/Generator.java === RCS file: /home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v retrieving revision 1.75 diff -u -r1.75 Generator.java --- jasper2/src/share/org/apache/jasper/compiler/Generator.java 21 Aug 2002 18:07:59 - 1.75 +++ jasper2/src/share/org/apache/jasper/compiler/Generator.java 22 Aug 2002 02:24:01 - @@ -2073,6 +2073,10 @@ out.printin(/* ); out.print(n.getName()); out.println( */); + +// Declare AT_BEGIN scripting variables + declareScriptingVars(n, VariableInfo.AT_BEGIN); + out.printil({); out.pushIndent(); @@ -2093,11 +2097,6 @@ generateSetters(n, tagHandlerVar, handlerInfo, true); -if (n.implementsTryCatchFinally()) { -out.printil(try {); -out.pushIndent(); -} - // Set the body if (findJspBody(n) == null) { /* @@ -2127,29 +2126,16 @@ out.printin(tagHandlerVar); out.println(.doTag();); - // Synchronize AT_BEGIN and AT_END scripting variables - syncScriptingVars(n, VariableInfo.AT_BEGIN); - syncScriptingVars(n, VariableInfo.AT_END); - - // TryCatchFinally - if (n.implementsTryCatchFinally()) { -out.popIndent(); // try - out.printil(} catch (Throwable _jspx_exception) {); - out.pushIndent(); - out.printin(tagHandlerVar); - out.println(.doCatch(_jspx_exception);); - out.popIndent(); -out.printil(} finally {); -out.pushIndent(); - out.printin(tagHandlerVar); - out.println(.doFinally();); -out.popIndent(); -out.println(}); - } - restoreScriptingVars(n); out.popIndent(); out.printil(}); + + // Synchronize AT_BEGIN scripting variables + syncScriptingVars(n, VariableInfo.AT_BEGIN); + + // Declare and synchronize AT_END scripting variables + declareScriptingVars(n, VariableInfo.AT_END); + syncScriptingVars(n, VariableInfo.AT_END); n.setEndJavaLine(out.getJavaLine()); } @@ -2162,21 +2148,25 @@ Object elem = vec.elementAt(i); if (elem instanceof VariableInfo) { VariableInfo varInfo = (VariableInfo) elem; - out.printin(varInfo.getClassName()); - out.print( ); - out.print(varInfo.getVarName()); - out.println( = null;); +if( varInfo.getDeclare() ) { +out.printin(varInfo.getClassName()); +out.print( ); +out.print(varInfo.getVarName()); +out.println( = null;); +} } else { TagVariableInfo tagVarInfo = (TagVariableInfo) elem; - String varName = tagVarInfo.getNameGiven(); - if (varName == null) { - varName = n.getTagData().getAttributeString( -tagVarInfo.getNameFromAttribute()); - } - out.printin(tagVarInfo.getClassName()); - out.print( ); - out.print(varName); - out.println( = null;); +if( tagVarInfo.getDeclare() ) { +String varName = tagVarInfo.getNameGiven(); +if (varName == null) { + varName = n.getTagData().getAttributeString( +tagVarInfo.getNameFromAttribute()); +} +out.printin(tagVarInfo.getClassName()); +out.print( ); +out.print(varName); +out.println( = null;); +} } } } @@ -2580,7 +2570,7 @@ throws JasperException { // XXX - A possible optimization here would be to check to see -// if the old child of the
[PATCH] jakarta-tomcat-jasper: PFD features and bugfixes 1
Attached is a patch to move us towards JSP 2.0 PFD feature-complete. More to come in the next few days... - Implemented the value attribute of jsp:doBody for classic tag handlers. - Stubbed out JspC with getJspConfig() so it compiles. - Added null check for addInclude() to handle the case where there are no preludes or codas. - Now accepts /WEB-INF/tags as well as /WEB-INF/tags/ for tag file default directory. - ParserController now uses path name to determine if the given element is a tag file instead of searching for tag directive. - In a tag file, an attribute directive with a fragment attribute must not allow a rtexprvalue attribute, and must fix its value to true. Fixed implementation to comply with spec. - Fixed preamble and postamble generator for Tag Files. Was not generating declarations, tag handler pools, methods buffer, helper fragment, etc. Generator now shares code between servlet and tag handler pre and post ambles. - Even though spec is not clear that they're required, added implicit objects to doTag() so they are available in tag files. -- Mark Roth, Java Software JSP 2.0 Specification Co-Lead Sun Microsystems, Inc. Index: jasper2/src/share/org/apache/jasper/JspC.java === RCS file: /home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v retrieving revision 1.12 diff -u -r1.12 JspC.java --- jasper2/src/share/org/apache/jasper/JspC.java 26 Jun 2002 16:50:38 - 1.12 +++ jasper2/src/share/org/apache/jasper/JspC.java 20 Aug 2002 05:22:50 - @@ -75,6 +75,7 @@ import org.apache.jasper.logging.Logger; import org.apache.jasper.logging.JasperLogger; +import org.apache.jasper.compiler.JspConfig; /** * Shell for the jspc compiler. Handles all options associated with the @@ -912,6 +913,15 @@ Constants.jasperLog.setVerbosityLevel(verbosityLevel); } + +/** + * Obtain JSP configuration informantion specified in web.xml. + */ +public JspConfig getJspConfig() { +// XXX - Stubbed out so Jasper compiles. +initServletContext(); +return new JspConfig( context ); +} } Index: jasper2/src/share/org/apache/jasper/compiler/Generator.java === RCS file: /home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v retrieving revision 1.71 diff -u -r1.71 Generator.java --- jasper2/src/share/org/apache/jasper/compiler/Generator.java 20 Aug 2002 01:42:38 - 1.71 +++ jasper2/src/share/org/apache/jasper/compiler/Generator.java 20 Aug 2002 05:22:53 - @@ -170,6 +170,7 @@ out.println(); page.visit(new DeclarationVisitor()); + out.println(); } /** @@ -329,23 +330,25 @@ } /** - * Generates the beginning of the static portion of the servelet. + * Generate preamble package name + * (shared by servlet and tag handler preamble generation) */ -private void generatePreamble(Node.Nodes page) throws JasperException { - - String servletPackageName = ctxt.getServletPackageName(); - String servletClassName = ctxt.getServletClassName(); - String serviceMethodName = Constants.SERVICE_METHOD_NAME; - - // First the package name: - - if (! .equals(servletPackageName) servletPackageName != null) { - out.printil(package + servletPackageName + ;); +private void genPreamblePackage( String packageName ) +throws JasperException +{ + if (! .equals(packageName) packageName != null) { + out.printil(package + packageName + ;); out.println(); } - - // Generate imports - +} + +/** + * Generate preamble imports + * (shared by servlet and tag handler preamble generation) + */ +private void genPreambleImports() +throws JasperException +{ Iterator iter = pageInfo.getImports().iterator(); while (iter.hasNext()) { out.printin(import ); @@ -353,31 +356,21 @@ out.println(;); } out.println(); +} - // Generate class declaration - - out.printin(public class ); - out.print (servletClassName); - out.print ( extends ); - out.print (pageInfo.getExtends()); - if (!pageInfo.isThreadSafe()) { - out.print(implements SingleThreadModel); - } - out.println( {); - out.pushIndent(); - - // Class body begins here - - generateDeclarations(page); - out.println(); - - // Static initializations here - +/** + * Generation of static initializers in preamble. + * For example, include list, el function map, prefix map. + * (shared by servlet and tag handler preamble generation) + */ +private void genPreambleStaticInitializers() +throws JasperException +{ // Static data for getIncludes() out.printil(private static java.util.Vector _jspx_includes;);
[Patch] jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
Couldn't figure out why it sometimes called ctxt.getOptions() and other times used the field options in which it had saved that value in the constructor. Replaced all calls outside the constructor with the field, and it still works for the simple cases I tested. Not a lot of overhead saved, but every bit helps. Also fixed one tab-spaces. Ian --- jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java.orig Tue Jul 9 11:21:21 2002 +++ jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java Tue Jul 9 11:21:55 2002 @@ -133,7 +133,7 @@ public Compiler(JspCompilationContext ctxt, JspServletWrapper jsw) { this.jsw = jsw; this.ctxt = ctxt; - this.errDispatcher = new ErrorDispatcher(); +this.errDispatcher = new ErrorDispatcher(); this.options = ctxt.getOptions(); } @@ -204,7 +204,7 @@ } catch (UnsupportedEncodingException ex) { // Try to get the java encoding from the javaEncoding // init parameter for JspServlet. - javaEncoding = ctxt.getOptions().getJavaEncoding(); + javaEncoding = options.getJavaEncoding(); if (javaEncoding != null) { try { osw = new OutputStreamWriter @@ -276,9 +276,9 @@ javac.setEncoding(javaEncoding); javac.setClasspath(path); //javac.setDestdir(new File(options.getScratchDir().getAbsolutePath())); -javac.setDebug(ctxt.getOptions().getClassDebugInfo()); +javac.setDebug(options.getClassDebugInfo()); javac.setSrcdir(srcPath); -javac.setOptimize(! ctxt.getOptions().getClassDebugInfo() ); +javac.setOptimize(! options.getClassDebugInfo() ); // Set the Java compiler to use if (options.getCompiler() != null) { -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]