kinman 2002/08/19 20:52:18 Modified: jasper2/src/share/org/apache/jasper EmbededServletOptions.java Options.java jasper2/src/share/org/apache/jasper/compiler Compiler.java PageInfo.java Parser.java ParserController.java TldLocationsCache.java Validator.java jasper2/src/share/org/apache/jasper/resources messages.properties Log: - Implemented JSP2.0 JSP configuration informantion in web.xml. Revision Changes Path 1.10 +16 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbededServletOptions.java Index: EmbededServletOptions.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbededServletOptions.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- EmbededServletOptions.java 16 Jul 2002 19:30:51 -0000 1.9 +++ EmbededServletOptions.java 20 Aug 2002 03:52:18 -0000 1.10 @@ -69,6 +69,7 @@ import org.apache.jasper.logging.Logger; import org.apache.jasper.compiler.TldLocationsCache; +import org.apache.jasper.compiler.JspConfig; import org.apache.jasper.xmlparser.ParserUtils; import java.util.*; @@ -164,6 +165,11 @@ private TldLocationsCache tldLocationsCache = null; /** + * Jsp config information + */ + JspConfig jspConfig = null; + + /** * Java platform encoding to generate the JSP * page servlet. */ @@ -279,6 +285,10 @@ return javaEncoding; } + public JspConfig getJspConfig() { + return jspConfig; + } + /** * Create an EmbededServletOptions object using data available from * ServletConfig and ServletContext. @@ -428,6 +438,9 @@ // Setup the global Tag Libraries location cache for this // web-application. tldLocationsCache = new TldLocationsCache(context); + + // Setup the jsp config info for this web app. + jspConfig = new JspConfig(context); } 1.8 +9 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java Index: Options.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Options.java 16 Jul 2002 19:30:51 -0000 1.7 +++ Options.java 20 Aug 2002 03:52:18 -0000 1.8 @@ -67,6 +67,7 @@ import javax.servlet.ServletContext; import org.apache.jasper.compiler.TldLocationsCache; +import org.apache.jasper.compiler.JspConfig; /** * A class to hold all init parameters specific to the JSP engine. @@ -161,4 +162,9 @@ * page servlet. */ public String getJavaEncoding(); + + /** + * Obtain JSP configuration informantion specified in web.xml. + */ + public JspConfig getJspConfig(); } 1.28 +20 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java Index: Compiler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- Compiler.java 16 Aug 2002 23:18:54 -0000 1.27 +++ Compiler.java 20 Aug 2002 03:52:18 -0000 1.28 @@ -194,6 +194,23 @@ { // Setup page info area pageInfo = new PageInfo(new BeanRepository(ctxt.getClassLoader())); + JspConfig jspConfig = options.getJspConfig(); + JspConfig.JspProperty jspProperty = + jspConfig.findJspProperty(ctxt.getJspFile()); + if (jspProperty != null) { + // If the current uri is matched by a pattern specified in + // a jsp-property-group in web.xml, initialize pageInfo with + // those properties. + if (jspProperty.isXml() != null) { + pageInfo.setIsXmlSpecified(true); + } + pageInfo.setIsXml(JspUtil.booleanValue(jspProperty.isXml())); + pageInfo.setPageEncoding(jspProperty.getPageEncoding()); + pageInfo.setELEnabled(JspUtil.booleanValue(jspProperty.isELEnabled())); + pageInfo.setScriptingEnabled(JspUtil.booleanValue(jspProperty.isScriptingEnabled())); + pageInfo.setIncludePrelude(jspProperty.getIncludePrelude()); + pageInfo.setIncludeCoda(jspProperty.getIncludeCoda()); + } String javaFileName = ctxt.getServletJavaFileName(); 1.8 +43 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageInfo.java Index: PageInfo.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageInfo.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- PageInfo.java 22 Jul 2002 20:35:27 -0000 1.7 +++ PageInfo.java 20 Aug 2002 03:52:18 -0000 1.8 @@ -93,12 +93,20 @@ private boolean scriptingEnabled = true; private boolean elEnabled = true; private boolean tagFile = false; + private boolean isXml = false; + private boolean isXmlSpecified = false; // true is there is a + // is-xml element + private Vector includePrelude; + private Vector includeCoda; + PageInfo(BeanRepository beanRepository) { this.beanRepository = beanRepository; this.tagLibraries = new Hashtable(); this.imports = new Vector(); this.includes = new Vector(); + this.includePrelude = new Vector(); + this.includeCoda = new Vector(); // Enter standard imports for(int i = 0; i < Constants.STANDARD_IMPORTS.length; i++) @@ -247,5 +255,37 @@ public boolean isTagFile() { return tagFile; + } + + public boolean isXml() { + return isXml; + } + + public void setIsXml(boolean xml) { + isXml = xml; + } + + public boolean isXmlSpecified() { + return isXmlSpecified; + } + + public void setIsXmlSpecified(boolean xmlSpecified) { + isXmlSpecified = xmlSpecified; + } + + public List getIncludePrelude() { + return includePrelude; + } + + public void setIncludePrelude(Vector prelude) { + includePrelude = prelude; + } + + public List getIncludeCoda() { + return includeCoda; + } + + public void setIncludeCoda(Vector coda) { + includeCoda = coda; } } 1.22 +31 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java Index: Parser.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- Parser.java 19 Aug 2002 23:06:01 -0000 1.21 +++ Parser.java 20 Aug 2002 03:52:18 -0000 1.22 @@ -63,6 +63,8 @@ import java.io.FileNotFoundException; import java.io.CharArrayWriter; import java.util.Hashtable; +import java.util.List; +import java.util.Iterator; import javax.servlet.jsp.tagext.TagLibraryInfo; import javax.servlet.jsp.tagext.TagInfo; import javax.servlet.jsp.tagext.TagFileInfo; @@ -135,9 +137,17 @@ Node.Root root = new Node.Root(null, reader.mark(), parent); + // For the Top level page, add inlcude-prelude and include-coda + PageInfo pageInfo = pc.getCompiler().getPageInfo(); + if (parent == null) { + parser.addInclude(root, pageInfo.getIncludePrelude()); + } while (reader.hasMoreInput()) { parser.parseElements(root); } + if (parent == null) { + parser.addInclude(root, pageInfo.getIncludeCoda()); + } Node.Nodes page = new Node.Nodes(root); return page; @@ -355,6 +365,24 @@ // Included file expanded here Node includeNode = new Node.IncludeDirective(attrs, start, parent); processIncludeDirective(attrs.getValue("file"), includeNode); + } + + /** + * Add a list of files. This is used for implementing include-prelude + * and include-coda of jsp-config element in web.xml + */ + private void addInclude(Node parent, List files) throws JasperException { + Iterator iter = files.iterator(); + while (iter.hasNext()) { + String file = (String) iter.next(); + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "file", "file", "CDATA", file); + + // Create a dummy Include directive node + Node includeNode = new Node.IncludeDirective(attrs, reader.mark(), + parent); + processIncludeDirective(file, includeNode); + } } /* 1.11 +38 -13 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java Index: ParserController.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ParserController.java 19 Aug 2002 23:06:01 -0000 1.10 +++ ParserController.java 20 Aug 2002 03:52:18 -0000 1.11 @@ -217,14 +217,31 @@ return parsedPage; } - //********************************************************************* - // Figure out input Document + /** ******************************************************************* + * Discover the properties of the page by scanning it. + * Properties to find out are: + * * Is it in XML syntax? + * * What is the the page encoding + * If these properties are already specified in the jsp-config element + * in web.xml, then they are used. + */ private void figureOutJspDocument(String file, String encoding, InputStreamReader reader) throws JasperException { + + PageInfo pageInfo = compiler.getPageInfo(); + if (pageInfo.isXmlSpecified()) { + isXml = pageInfo.isXml(); + } + if (pageInfo.getPageEncoding() != null) { + newEncoding = pageInfo.getPageEncoding(); + } + if (pageInfo.isXmlSpecified() && pageInfo.getPageEncoding() != null) + return; + JspReader jspReader; try { jspReader = new JspReader(ctxt, file, encoding, reader, @@ -235,15 +252,23 @@ jspReader.setSingleFile(true); Mark startMark = jspReader.mark(); - // Check for the jsp:root tag - // No check for xml prolog, since nothing prevents a page - // to output XML and still use JSP syntax. - jspReader.reset(startMark); - Mark mark = jspReader.skipUntil(JSP_ROOT_TAG); - if (mark != null) { - isXml = true; - } else { - isXml = false; + if (!pageInfo.isXmlSpecified()) { + // Check for the jsp:root tag + // No check for xml prolog, since nothing prevents a page + // to output XML and still use JSP syntax. + jspReader.reset(startMark); + Mark mark = jspReader.skipUntil(JSP_ROOT_TAG); + if (mark != null) { + isXml = true; + } else { + isXml = false; + } + } + + if (pageInfo.getPageEncoding() != null) { + // XXX isTagFile is not correctly set, but it will be determined + // elsewhere, and not here anyway. + return; } newEncoding = null; @@ -253,8 +278,8 @@ // FIXME: We assume xml parser will take care of // encoding for page in XML syntax. Correct? if (!isXml) { - jspReader.reset(startMark); - while (jspReader.skipUntil("<%@") != null) { + jspReader.reset(startMark); + while (jspReader.skipUntil("<%@") != null) { jspReader.skipSpaces(); boolean tIsTagFile = jspReader.matches("tag "); if (tIsTagFile || jspReader.matches("page")) { 1.5 +6 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TldLocationsCache.java 20 Jun 2002 23:00:43 -0000 1.4 +++ TldLocationsCache.java 20 Aug 2002 03:52:18 -0000 1.5 @@ -173,6 +173,12 @@ this.getClass().getClassLoader(); ParserUtils pu = ParserUtils.createParserUtils(cl); TreeNode webtld = pu.parseXMLDocument(WEB_XML, is); + + // Allow taglib be an element of the root or jsp-config (JSP2.0) + TreeNode jspConfig = webtld.findChild("jsp-config"); + if (jspConfig != null) { + webtld = jspConfig; + } Iterator taglibs = webtld.findChildren("taglib"); while (taglibs.hasNext()) { 1.23 +4 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java Index: Validator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- Validator.java 19 Aug 2002 18:44:42 -0000 1.22 +++ Validator.java 20 Aug 2002 03:52:18 -0000 1.23 @@ -754,7 +754,7 @@ // validate expression syntax if string contains // expression(s) - if (value.indexOf("${") != -1 /* && isELEnabled */) { + if (value.indexOf("${") != -1 && pageInfo.isELEnabled()) { JspUtil.validateExpressions(n.getStart(), value, err); result = new Node.JspAttribute(qName, uri, localName, value, false, true, 1.24 +2 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties Index: messages.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- messages.properties 19 Aug 2002 16:54:16 -0000 1.23 +++ messages.properties 20 Aug 2002 03:52:18 -0000 1.24 @@ -283,3 +283,4 @@ jsp.error.missing.tagInfo=TagInfo object for {0} is missing from TLD jsp.error.fragmentwithtype=Both 'fragment' and 'type' attributes specified in tag directive jsp.error.fragmentWithDeclareOrScope=Both 'fragment' and 'declare' or 'scope' attributes specified in variable directive +jsp.warning.bad.urlpattern.propertygroup=Bad value {0} in the url-pattern subelement in web.xml
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>