cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
luehe 2005/03/30 12:27:22 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Do not add taglib to cache if it's already there, i.e., if the cache already contains a taglib with the given uri. This is consistent with how this is handled in the standard syntax case. Revision ChangesPath 1.84 +3 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.83 retrieving revision 1.84 diff -u -r1.83 -r1.84 --- JspDocumentParser.java16 Aug 2004 22:35:37 - 1.83 +++ JspDocumentParser.java30 Mar 2005 20:27:22 - 1.84 @@ -768,7 +768,9 @@ } if (taglibInfo != null) { -pageInfo.addTaglib(uri, taglibInfo); +if (pageInfo.getTaglib(uri) == null) { +pageInfo.addTaglib(uri, taglibInfo); +} pageInfo.pushPrefixMapping(prefix, uri); } else { pageInfo.pushPrefixMapping(prefix, null); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java
markt 2004/10/04 13:10:14 Modified:jasper2/src/share/org/apache/jasper/compiler Tag: tomcat_4_branch JspDocumentParser.java ParserController.java Log: Fix bug 19778. Ensure JSPs in XML form using UTF-8 encoding (or any other) are correctly handled. - Based on a patch provided by 'marcello' Revision ChangesPath No revision No revision 1.4.2.8 +4 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.4.2.7 retrieving revision 1.4.2.8 diff -u -r1.4.2.7 -r1.4.2.8 --- JspDocumentParser.java25 Aug 2004 20:53:30 - 1.4.2.7 +++ JspDocumentParser.java4 Oct 2004 20:10:14 - 1.4.2.8 @@ -76,13 +76,13 @@ */ public JspDocumentParser(ParserController pc, String path, - InputStreamReader reader) { + InputStream stream) { this.parserController = pc; this.ctxt = pc.getJspCompilationContext(); this.taglibs = pc.getCompiler().getPageInfo().getTagLibraries(); this.err = pc.getCompiler().getErrorDispatcher(); this.path = path; -this.inputSource = new InputSource(reader); +this.inputSource = new InputSource(stream); } /* @@ -92,9 +92,9 @@ */ public static Node.Nodes parse(ParserController pc, String path, - InputStreamReader reader, + InputStream stream, Node parent) throws JasperException { -JspDocumentParser handler = new JspDocumentParser(pc, path, reader); +JspDocumentParser handler = new JspDocumentParser(pc, path, stream); handler.current = parent; Node.Nodes pageNodes = null; 1.4.2.5 +25 -12 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.4.2.4 retrieving revision 1.4.2.5 diff -u -r1.4.2.4 -r1.4.2.5 --- ParserController.java 25 Aug 2004 20:53:32 - 1.4.2.4 +++ ParserController.java 4 Oct 2004 20:10:14 - 1.4.2.5 @@ -124,6 +124,7 @@ Node.Nodes parsedPage = null; String absFileName = resolveFileName(inFileName); String encoding = topFileEncoding; +InputStream stream = null; InputStreamReader reader = null; try { // Figure out what type of JSP document we are dealing with @@ -146,11 +147,12 @@ // dispatch to the proper parser -reader = getReader(absFileName, encoding); if (isXml) { +stream = getStream(absFileName); parsedPage = JspDocumentParser.parse(this, absFileName, - reader, parent); + stream, parent); } else { +reader = getReader(absFileName, encoding); JspReader r = new JspReader(ctxt, absFileName, encoding, reader, compiler.getErrorDispatcher()); @@ -164,6 +166,13 @@ } catch (Exception any) { } } + +if (stream != null) { +try { +stream.close(); +} catch (Exception any) { +} +} } return parsedPage; @@ -201,8 +210,8 @@ newEncoding = null; // Figure out the encoding of the page -// FIXME: We assume xml parser will take care of -// encoding for page in XML syntax. Correct? +// xml parser will take care of encoding for +// page in XML syntax since we pass it a stream if (!isXml) { jspReader.reset(startMark); while (jspReader.skipUntil(%@) != null) { @@ -253,18 +262,22 @@ return fileName; } -private InputStreamReader getReader(String file, String encoding) -throws FileNotFoundException, JasperException +private InputStream getStream(String file) +throws
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Validator.java
markt 2004/08/22 08:52:03 Modified:jasper2/src/share/org/apache/jasper/compiler Tag: tomcat_4_branch JspDocumentParser.java Validator.java Log: CVS: -- CVS: PR: CVS: If this change addresses a PR in the problem report tracking CVS: database, then enter the PR number(s) here. CVS: Obtained from: CVS: If this change has been taken from another system, such as NCSA, CVS: then name the system in this line, otherwise delete it. CVS: Submitted by: CVS: If this code has been contributed to Apache by someone else; i.e., CVS: they sent us a patch or a new module, then include their name/email CVS: address here. If this is your work then delete this line. CVS: Reviewed by: CVS: If we are doing pre-commit code reviews and someone else has CVS: reviewed your changes, include their name(s) here. CVS: If you have not had it reviewed then delete this line. Revision ChangesPath No revision No revision 1.4.2.6 +8 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.4.2.5 retrieving revision 1.4.2.6 diff -u -r1.4.2.5 -r1.4.2.6 --- JspDocumentParser.java22 Aug 2004 12:35:58 - 1.4.2.5 +++ JspDocumentParser.java22 Aug 2004 15:52:03 - 1.4.2.6 @@ -85,6 +85,8 @@ private static final String XMLNS = xmlns:; private static final String XMLNS_JSP = xmlns:jsp; private static final String JSP_VERSION = version; +private static final String XMLNS_XSI = xmlns:xsi; +private static final String XSI_SCHEMA_LOCATION = xsi:schemaLocation; private static final String URN_JSPTLD = urn:jsptld:; private static final String LEXICAL_HANDLER_PROPERTY = http://xml.org/sax/properties/lexical-handler;; @@ -432,7 +434,9 @@ for (int i=0; ilen; i++) { String qName = attrs.getQName(i); if (!qName.startsWith(XMLNS_JSP) - !qName.startsWith(JSP_VERSION)) { + !qName.startsWith(JSP_VERSION) + !qName.startsWith(XMLNS_XSI) + !qName.startsWith(XSI_SCHEMA_LOCATION)) { // get the prefix String prefix = null; 1.11.2.5 +4 -3 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.11.2.4 retrieving revision 1.11.2.5 diff -u -r1.11.2.4 -r1.11.2.5 --- Validator.java22 Aug 2004 12:35:58 - 1.11.2.4 +++ Validator.java22 Aug 2004 15:52:03 - 1.11.2.5 @@ -255,6 +255,7 @@ private ErrorDispatcher err; private static final JspUtil.ValidAttribute[] jspRootAttrs = { +new JspUtil.ValidAttribute(xsi:schemaLocation), new JspUtil.ValidAttribute(version, true) }; private static final JspUtil.ValidAttribute[] includeDirectiveAttrs = { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Validator.java
Sorry, finger trouble on my part. The log should have been: Fix bug 13956. XSI Namespace Declaration should not be interpreted as a tag library declaration -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, August 22, 2004 4:52 PM To: [EMAIL PROTECTED] Subject: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/comp iler JspDocumentParser.java Validator.java markt 2004/08/22 08:52:03 Modified:jasper2/src/share/org/apache/jasper/compiler Tag: tomcat_4_branch JspDocumentParser.java Validator.java Log: CVS: -- CVS: PR: CVS: If this change addresses a PR in the problem report tracking CVS: database, then enter the PR number(s) here. CVS: Obtained from: CVS: If this change has been taken from another system, such as NCSA, CVS: then name the system in this line, otherwise delete it. CVS: Submitted by: CVS: If this code has been contributed to Apache by someone else; i.e., CVS: they sent us a patch or a new module, then include their name/email CVS: address here. If this is your work then delete this line. CVS: Reviewed by: CVS: If we are doing pre-commit code reviews and someone else has CVS: reviewed your changes, include their name(s) here. CVS: If you have not had it reviewed then delete this line. Revision ChangesPath No revision No revision 1.4.2.6 +8 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/comp iler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/j asper/compiler/JspDocumentParser.java,v retrieving revision 1.4.2.5 retrieving revision 1.4.2.6 diff -u -r1.4.2.5 -r1.4.2.6 --- JspDocumentParser.java 22 Aug 2004 12:35:58 - 1.4.2.5 +++ JspDocumentParser.java 22 Aug 2004 15:52:03 - 1.4.2.6 @@ -85,6 +85,8 @@ private static final String XMLNS = xmlns:; private static final String XMLNS_JSP = xmlns:jsp; private static final String JSP_VERSION = version; +private static final String XMLNS_XSI = xmlns:xsi; +private static final String XSI_SCHEMA_LOCATION = xsi:schemaLocation; private static final String URN_JSPTLD = urn:jsptld:; private static final String LEXICAL_HANDLER_PROPERTY = http://xml.org/sax/properties/lexical-handler;; @@ -432,7 +434,9 @@ for (int i=0; ilen; i++) { String qName = attrs.getQName(i); if (!qName.startsWith(XMLNS_JSP) - !qName.startsWith(JSP_VERSION)) { + !qName.startsWith(JSP_VERSION) + !qName.startsWith(XMLNS_XSI) + !qName.startsWith(XSI_SCHEMA_LOCATION)) { // get the prefix String prefix = null; 1.11.2.5 +4 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/comp iler/Validator.java Index: Validator.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/j asper/compiler/Validator.java,v retrieving revision 1.11.2.4 retrieving revision 1.11.2.5 diff -u -r1.11.2.4 -r1.11.2.5 --- Validator.java 22 Aug 2004 12:35:58 - 1.11.2.4 +++ Validator.java 22 Aug 2004 15:52:03 - 1.11.2.5 @@ -255,6 +255,7 @@ private ErrorDispatcher err; private static final JspUtil.ValidAttribute[] jspRootAttrs = { +new JspUtil.ValidAttribute(xsi:schemaLocation), new JspUtil.ValidAttribute(version, true) }; private static final JspUtil.ValidAttribute[] includeDirectiveAttrs = { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java
kinman 2004/08/16 15:35:38 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java Log: - Close any InputStream open in JspDocumentParser. Revision ChangesPath 1.83 +24 -37 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.82 retrieving revision 1.83 diff -u -r1.82 -r1.83 --- JspDocumentParser.java13 Jul 2004 20:38:56 - 1.82 +++ JspDocumentParser.java16 Aug 2004 22:35:37 - 1.83 @@ -18,6 +18,8 @@ import java.io.CharArrayWriter; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; + import java.util.Iterator; import java.util.List; import java.util.jar.JarFile; @@ -166,24 +168,32 @@ // Parse the input SAXParser saxParser = getSAXParser(false, jspDocParser); +InputStream inStream = null; try { -saxParser.parse( -jspDocParser.getInputSource( -path, -jarFile, -jspDocParser.ctxt, -jspDocParser.err), -jspDocParser); +inStream = JspUtil.getInputStream(path, jarFile, + jspDocParser.ctxt, + jspDocParser.err); +saxParser.parse(new InputSource(inStream), jspDocParser); } catch (EnableDTDValidationException e) { saxParser = getSAXParser(true, jspDocParser); jspDocParser.isValidating = true; -saxParser.parse( -jspDocParser.getInputSource( -path, -jarFile, -jspDocParser.ctxt, -jspDocParser.err), -jspDocParser); +if (inStream != null) { +try { +inStream.close(); +} catch (Exception any) { +} +} +inStream = JspUtil.getInputStream(path, jarFile, + jspDocParser.ctxt, + jspDocParser.err); +saxParser.parse(new InputSource(inStream), jspDocParser); +} finally { +if (inStream != null) { +try { +inStream.close(); +} catch (Exception any) { +} +} } if (parent == null) { @@ -1369,29 +1379,6 @@ xmlReader.setErrorHandler(jspDocParser); return saxParser; -} - -/* - * Gets an InputSource to the JSP document or tag file to be parsed. - * - * @param path The path to the JSP document or tag file to be parsed - * @param jarFile The JAR file from which to read the JSP document or tag - * file, or null if the JSP document or tag file is to be read from the - * filesystem - * @param ctxt The JSP compilation context - * @param err The error dispatcher - * - * @return An InputSource to the requested JSP document or tag file - */ -private InputSource getInputSource( -String path, -JarFile jarFile, -JspCompilationContext ctxt, -ErrorDispatcher err) -throws Exception { - -return new InputSource( -JspUtil.getInputStream(path, jarFile, ctxt, err)); } /* 1.54 +8 -16 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.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- ParserController.java 12 Jul 2004 22:54:33 - 1.53 +++ ParserController.java 16 Aug 2004 22:35:37 - 1.54 @@ -192,22 +192,14 @@ // Dispatch to the appropriate parser if (isXml) { // JSP document (XML syntax) - InputStream inStream = null; - try { - parsedPage = JspDocumentParser.parse(this, absFileName, - jarFile, parent, -
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
luehe 2004/08/10 16:37:50 Modified:jasper2/src/share/org/apache/jasper/compiler Tag: TOMCAT_5_0 JspDocumentParser.java Log: Ported fix for Bugilla 30067 (Scripting elements are disallowed here exception behind scriptless tag) Revision ChangesPath No revision No revision 1.80.2.2 +5 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.80.2.1 retrieving revision 1.80.2.2 diff -u -r1.80.2.1 -r1.80.2.2 --- JspDocumentParser.java10 Aug 2004 23:33:02 - 1.80.2.1 +++ JspDocumentParser.java10 Aug 2004 23:37:50 - 1.80.2.2 @@ -640,12 +640,13 @@ tagDependentNesting--; } +if (scriptlessBodyNode != null + current.equals(scriptlessBodyNode)) { +scriptlessBodyNode = null; +} + if (current.getParent() != null) { current = current.getParent(); -if (scriptlessBodyNode != null - current.equals(scriptlessBodyNode)) { -scriptlessBodyNode = null; -} } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
luehe 2004/07/13 13:38:56 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Fixed Bugilla 30067 (Scripting elements are disallowed here exception behind scriptless tag) Revision ChangesPath 1.82 +5 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.81 retrieving revision 1.82 diff -u -r1.81 -r1.82 --- JspDocumentParser.java13 Jul 2004 18:40:08 - 1.81 +++ JspDocumentParser.java13 Jul 2004 20:38:56 - 1.82 @@ -640,12 +640,13 @@ tagDependentNesting--; } +if (scriptlessBodyNode != null + current.equals(scriptlessBodyNode)) { +scriptlessBodyNode = null; +} + if (current.getParent() != null) { current = current.getParent(); -if (scriptlessBodyNode != null - current.equals(scriptlessBodyNode)) { -scriptlessBodyNode = null; -} } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
kinman 2004/04/16 16:22:30 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: - Fix a bug where a custom tag with tagdependent body type is not handled correctly in XML syntax. The fix would have been trivial if not for the cases where jsp:attribute and/or jsp:body is present. Revision ChangesPath 1.79 +97 -10 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.78 retrieving revision 1.79 diff -u -r1.78 -r1.79 --- JspDocumentParser.java13 Apr 2004 22:55:50 - 1.78 +++ JspDocumentParser.java16 Apr 2004 23:22:30 - 1.79 @@ -102,13 +102,18 @@ private boolean directivesOnly; private boolean isTop; +// Nesting level of Tag dependent bodies +private int tagDependentNesting = 0; +// Flag set to delay incrmenting tagDependentNesting until jsp:body +// is first encountered +private boolean tagDependentPending = false; + /* * Constructor */ public JspDocumentParser( ParserController pc, String path, -JarFile jarFile, boolean isTagFile, boolean directivesOnly) { this.parserController = pc; @@ -139,7 +144,7 @@ throws JasperException { JspDocumentParser jspDocParser = -new JspDocumentParser(pc, path, jarFile, isTagFile, directivesOnly); +new JspDocumentParser(pc, path, isTagFile, directivesOnly); Node.Nodes pageNodes = null; try { @@ -324,7 +329,52 @@ Node node = null; -if (JSP_URI.equals(uri)) { +if (tagDependentPending JSP_URI.equals(uri) + localName.equals(BODY_ACTION)) { +tagDependentNesting++; +current = +parseStandardAction( +qName, +localName, +nonTaglibAttrs, +nonTaglibXmlnsAttrs, +taglibAttrs, +startMark, +current); +tagDependentPending = false; +return; +} + +if (tagDependentPending JSP_URI.equals(uri) + localName.equals(ATTRIBUTE_ACTION)) { +current = +parseStandardAction( +qName, +localName, +nonTaglibAttrs, +nonTaglibXmlnsAttrs, +taglibAttrs, +startMark, +current); +return; +} + +if (tagDependentPending) { +tagDependentPending = false; +tagDependentNesting++; +} + +if (tagDependentNesting 0) { +node = +new Node.UninterpretedTag( +qName, +localName, +nonTaglibAttrs, +nonTaglibXmlnsAttrs, +taglibAttrs, +startMark, +current); +} else if (JSP_URI.equals(uri)) { node = parseStandardAction( qName, @@ -357,17 +407,15 @@ current); } else { // custom action -Node.CustomTag custom = (Node.CustomTag) node; - String bodyType; - if (custom.getTagInfo() != null) { - bodyType = custom.getTagInfo().getBodyContent(); - } else { - bodyType = custom.getTagFileInfo().getTagInfo().getBodyContent(); - } + String bodyType = getBodyType((Node.CustomTag) node); + if (scriptlessBodyNode == null bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS)) { scriptlessBodyNode = node; } +else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) { +tagDependentPending = true; +} } } @@ -425,6 +473,22 @@ } } } + +if (!isAllSpace tagDependentPending) { +tagDependentPending = false; +tagDependentNesting++; +} + +if (tagDependentNesting 0) { +if (charBuffer.length() 0) { +new Node.TemplateText(charBuffer.toString(), startMark, current); +
Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
[EMAIL PROTECTED] wrote: luehe 2004/02/13 16:46:01 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Fixed Bugtraq 4994881 (Parser for JSP pages in XML syntax ignores custom action's body type) Sorry this commit is so close to the tagging, but it's an important fix. I'll never pass on an opportunity to mess up a build, obviously ;) Rémy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
luehe 2004/02/13 16:46:01 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Fixed Bugtraq 4994881 (Parser for JSP pages in XML syntax ignores custom action's body type) Sorry this commit is so close to the tagging, but it's an important fix. Revision ChangesPath 1.76 +54 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- JspDocumentParser.java19 Jan 2004 10:34:30 - 1.75 +++ JspDocumentParser.java14 Feb 2004 00:46:00 - 1.76 @@ -116,6 +116,13 @@ // Node representing the XML element currently being parsed private Node current; +/* + * Outermost (in the nesting hierarchy) node whose body is declared to be + * scriptless. If a node's body is declared to be scriptless, all its + * nested nodes must be scriptless, too. + */ +private Node scriptlessBodyNode; + private Locator locator; //Mark representing the start of the current element. Note @@ -393,6 +400,19 @@ taglibAttrs, startMark, current); +} else { +// custom action +Node.CustomTag custom = (Node.CustomTag) node; + String bodyType; + if (custom.getTagInfo() != null) { + bodyType = custom.getTagInfo().getBodyContent(); + } else { + bodyType = custom.getTagFileInfo().getTagInfo().getBodyContent(); + } +if (scriptlessBodyNode == null + bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS)) { +scriptlessBodyNode = node; +} } } @@ -598,6 +618,10 @@ if (current.getParent() != null) { current = current.getParent(); +if (scriptlessBodyNode != null + current.equals(scriptlessBodyNode)) { +scriptlessBodyNode = null; +} } } @@ -786,6 +810,15 @@ current); processIncludeDirective(nonTaglibAttrs.getValue(file), node); } else if (localName.equals(DECLARATION_ACTION)) { +if (scriptlessBodyNode != null) { +// We're nested inside a node whose body is +// declared to be scriptless +throw new SAXParseException( +Localizer.getMessage( +jsp.error.no.scriptlets, +localName), +locator); +} node = new Node.Declaration( qName, @@ -794,6 +827,15 @@ start, current); } else if (localName.equals(SCRIPTLET_ACTION)) { +if (scriptlessBodyNode != null) { +// We're nested inside a node whose body is +// declared to be scriptless +throw new SAXParseException( +Localizer.getMessage( +jsp.error.no.scriptlets, +localName), +locator); +} node = new Node.Scriptlet( qName, @@ -802,6 +844,15 @@ start, current); } else if (localName.equals(EXPRESSION_ACTION)) { +if (scriptlessBodyNode != null) { +// We're nested inside a node whose body is +// declared to be scriptless +throw new SAXParseException( +Localizer.getMessage( +jsp.error.no.scriptlets, +localName), +locator); +} node = new Node.Expression( qName, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
remm2004/01/19 02:34:30 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: - Fix classcast exception is JSP document parser. - Bug 26191, submitted by Trond Aasan. Revision ChangesPath 1.75 +8 -9 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.74 retrieving revision 1.75 diff -u -r1.74 -r1.75 --- JspDocumentParser.java25 Nov 2003 22:59:27 - 1.74 +++ JspDocumentParser.java19 Jan 2004 10:34:30 - 1.75 @@ -230,13 +230,12 @@ } catch (IOException ioe) { jspDocParser.err.jspError(jsp.error.data.file.read, path, ioe); +} catch (SAXParseException e) { +jspDocParser.err.jspError +(new Mark(path, e.getLineNumber(), e.getColumnNumber()), + e.getMessage()); } catch (Exception e) { -jspDocParser.err.jspError( -new Mark( -path, -((SAXParseException)e).getLineNumber(), -((SAXParseException)e).getColumnNumber()), -e.getMessage()); +jspDocParser.err.jspError(e); } return pageNodes; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
kinman 2003/11/25 10:51:47 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: - In XML syntax, recognize \$ escape sequence in template text. Revision ChangesPath 1.73 +11 -8 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- JspDocumentParser.java24 Nov 2003 23:51:10 - 1.72 +++ JspDocumentParser.java25 Nov 2003 18:51:47 - 1.73 @@ -523,18 +523,21 @@ ttext.write(ch); lastCh = ch; } +} else if (lastCh == '\\' ch == '$') { +ttext.write('$'); +ch = 0; // Not start of EL anymore } else { -if ((lastCh == '$') (ch != '{')) { -ttext.write('$'); +if (lastCh == '$' || lastCh == '\\') { +ttext.write(lastCh); } -if (ch != '$') { +if (ch != '$' ch != '\\') { ttext.write(ch); } } lastCh = ch; } -if (lastCh == '$') { -ttext.write('$'); +if (lastCh == '$' || lastCh == '\\') { +ttext.write(lastCh); } if (ttext.size() 0) { new Node.TemplateText(ttext.toString(), startMark, current); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
kinman 2003/11/25 14:59:27 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: - Make sure that white spaces in template texts around ![CDATA[...]] are trimmed. Revision ChangesPath 1.74 +9 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- JspDocumentParser.java25 Nov 2003 18:51:47 - 1.73 +++ JspDocumentParser.java25 Nov 2003 22:59:27 - 1.74 @@ -615,6 +615,9 @@ * See org.xml.sax.ext.LexicalHandler. */ public void comment(char[] buf, int offset, int len) throws SAXException { + +processChars(); // Flush char buffer and remove white spaces + // ignore comments in the DTD if (!inDTD) { startMark = @@ -630,6 +633,8 @@ * See org.xml.sax.ext.LexicalHandler. */ public void startCDATA() throws SAXException { + +processChars(); // Flush char buffer and remove white spaces startMark = new Mark(path, locator.getLineNumber(), locator.getColumnNumber()); } @@ -638,7 +643,7 @@ * See org.xml.sax.ext.LexicalHandler. */ public void endCDATA() throws SAXException { -// do nothing +processChars(); // Flush char buffer and remove white spaces } /* - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
kinman 2003/11/24 15:51:10 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: - Fix 24779: Jasper fails to compile a valid JSP document (xml syntax) when an EL string in template text contains a []. The fix to to buffer and concatenate template text strings and only start processing the texts when they are all in one piece. This, BTW, also fixes the bug that somestimes trims the white spaces that trails template texts. Revision ChangesPath 1.72 +42 -15 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- JspDocumentParser.java22 Nov 2003 02:09:34 - 1.71 +++ JspDocumentParser.java24 Nov 2003 23:51:10 - 1.72 @@ -90,6 +90,7 @@ * syntax. * * @author Jan Luehe + * @author Kin-man Chung */ class JspDocumentParser @@ -110,6 +111,7 @@ private JspCompilationContext ctxt; private PageInfo pageInfo; private String path; +private StringBuffer charBuffer; // Node representing the XML element currently being parsed private Node current; @@ -287,6 +289,8 @@ AttributesImpl nonTaglibAttrs = null; AttributesImpl nonTaglibXmlnsAttrs = null; +processChars(); + checkPrefixes(uri, qName, attrs); if (directivesOnly @@ -399,14 +403,33 @@ /* * Receives notification of character data inside an element. * + * The SAX does not call this method with all of the template text, but may + * invoke this method with chunks of it. This is a problem when we try + * to determine if the text contains only whitespaces, or when we are + * looking for an EL expression string. Therefore it is necessary to + * buffer and concatenate the chunks and process the concatenated text + * later (at beginTag and endTag) + * * @param buf The characters * @param offset The start position in the character array * @param len The number of characters to use from the character array * * @throws SAXException */ -public void characters(char[] buf, int offset, int len) -throws SAXException { +public void characters(char[] buf, int offset, int len) { + +if (charBuffer == null) { +charBuffer = new StringBuffer(); +} +charBuffer.append(buf, offset, len); +} + +private void processChars() throws SAXException { + +if (charBuffer == null) { +return; +} + /* * JSP.6.1.1: All textual nodes that have only white space are to be * dropped from the document, except for nodes in a jsp:text element, @@ -418,11 +441,11 @@ boolean isAllSpace = true; if (!(current instanceof Node.JspText) !(current instanceof Node.NamedAttribute)) { -for (int i = offset; i offset + len; i++) { -if (!(buf[i] == ' ' -|| buf[i] == '\n' -|| buf[i] == '\r' -|| buf[i] == '\t')) { +for (int i = 0; i charBuffer.length(); i++) { +if (!(charBuffer.charAt(i) == ' ' +|| charBuffer.charAt(i) == '\n' +|| charBuffer.charAt(i) == '\r' +|| charBuffer.charAt(i) == '\t')) { isAllSpace = false; break; } @@ -436,10 +459,10 @@ int column = startMark.getColumnNumber(); CharArrayWriter ttext = new CharArrayWriter(); -int limit = offset + len; int lastCh = 0; -for (int i = offset; i limit; i++) { -int ch = buf[i]; +for (int i = 0; i charBuffer.length(); i++) { + +int ch = charBuffer.charAt(i); if (ch == '\n') { column = 1; line++; @@ -463,7 +486,7 @@ boolean doubleQ = false; lastCh = 0; for (;; i++) { -if (i = limit) { +if (i = charBuffer.length()) { throw new SAXParseException( Localizer.getMessage( jsp.error.unterminated, @@ -471,7 +494,7 @@ locator); } -
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
kinman 2003/11/21 18:09:35 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: - Fix bugzilla 24904: Nested custom tag causes bogus compilation errors. Revision ChangesPath 1.71 +10 -7 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- JspDocumentParser.java1 Sep 2003 23:22:56 - 1.70 +++ JspDocumentParser.java22 Nov 2003 02:09:34 - 1.71 @@ -99,6 +99,7 @@ private static final String JSP_VERSION = version; private static final String LEXICAL_HANDLER_PROPERTY = http://xml.org/sax/properties/lexical-handler;; +private static final String JSP_URI = http://java.sun.com/JSP/Page;; private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION = new EnableDTDValidationException( @@ -288,12 +289,13 @@ checkPrefixes(uri, qName, attrs); -if (directivesOnly !localName.startsWith(DIRECTIVE_ACTION)) { +if (directivesOnly +!(JSP_URI.equals(uri) localName.startsWith(DIRECTIVE_ACTION))) { return; } // jsp:text must not have any subelements -if (TEXT_ACTION.equals(current.getLocalName())) { +if (JSP_URI.equals(uri) TEXT_ACTION.equals(current.getLocalName())) { throw new SAXParseException( Localizer.getMessage(jsp.error.text.has_subelement), locator); @@ -357,7 +359,7 @@ Node node = null; -if (http://java.sun.com/JSP/Page.equals(uri)) { +if (JSP_URI.equals(uri)) { node = parseStandardAction( qName, @@ -525,7 +527,8 @@ public void endElement(String uri, String localName, String qName) throws SAXException { -if (directivesOnly !localName.startsWith(DIRECTIVE_ACTION)) { +if (directivesOnly +!(JSP_URI.equals(uri) localName.startsWith(DIRECTIVE_ACTION))) { return; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
ecarmich2003/09/01 16:22:56 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Set Node.startMark correctly in JSP document nodes created from character data. This fixes incorrect SMAPping of template text nodes containing line feeds, and incorrect error reporting for unparseable EL expression nodes. Revision ChangesPath 1.70 +50 -18 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- JspDocumentParser.java1 Sep 2003 00:17:35 - 1.69 +++ JspDocumentParser.java1 Sep 2003 23:22:56 - 1.70 @@ -115,6 +115,18 @@ private Locator locator; +//Mark representing the start of the current element. Note +//that locator.getLineNumber() and locator.getColumnNumber() +//return the line and column numbers for the character +//immediately _following_ the current element. The underlying +//XMl parser eats white space that is not part of character +//data, so for Nodes that are not created from character data, +//this is the best we can do. But when we parse character data, +//we get an accurate starting location by starting with startMark +//as set by the previous element, and updating it as we advance +//through the characters. +private Mark startMark; + // Flag indicating whether we are inside DTD declarations private boolean inDTD; @@ -287,7 +299,7 @@ locator); } -Mark start = +startMark = new Mark(path, locator.getLineNumber(), locator.getColumnNumber()); if (attrs != null) { @@ -353,7 +365,7 @@ nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, -start, +startMark, current); } else { node = @@ -364,7 +376,7 @@ nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, -start, +startMark, current); if (node == null) { node = @@ -374,7 +386,7 @@ nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, -start, +startMark, current); } } @@ -417,21 +429,31 @@ if ((current instanceof Node.JspText) || (current instanceof Node.NamedAttribute) || !isAllSpace) { -Mark start = -new Mark( -path, -locator.getLineNumber(), -locator.getColumnNumber()); + +int line = startMark.getLineNumber(); +int column = startMark.getColumnNumber(); CharArrayWriter ttext = new CharArrayWriter(); int limit = offset + len; int lastCh = 0; for (int i = offset; i limit; i++) { int ch = buf[i]; +if (ch == '\n') { +column = 1; +line++; +} else { +column++; +} if (lastCh == '$' ch == '{') { if (ttext.size() 0) { -new Node.TemplateText(ttext.toString(), start, current); +new Node.TemplateText( +ttext.toString(), +startMark, +current); ttext = new CharArrayWriter(); +//We subtract two from the column number to +//account for the '${' that we've already parsed +startMark = new Mark(path, line, column - 2); } // following ${ to first unquoted } i++; @@ -448,6 +470,12 @@ } ch = buf[i]; +if (ch == '\n') { +column = 1; +line++; +} else { +column++; +} if (lastCh == '\\' (singleQ || doubleQ)) { ttext.write(ch);
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
ecarmich2003/08/31 17:17:35 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Expand wildcard imports Remove unused imports Remove tabs Revision ChangesPath 1.69 +874 -644 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- JspDocumentParser.java29 Aug 2003 19:31:22 - 1.68 +++ JspDocumentParser.java1 Sep 2003 00:17:35 - 1.69 @@ -57,22 +57,33 @@ * information on the Apache Software Foundation, please see * http://www.apache.org/. * - */ + */ package org.apache.jasper.compiler; -import java.io.*; -import java.util.*; +import java.io.CharArrayWriter; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; import java.util.jar.JarFile; -import javax.servlet.jsp.tagext.*; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.parsers.ParserConfigurationException; + +import javax.servlet.jsp.tagext.TagFileInfo; +import javax.servlet.jsp.tagext.TagInfo; +import javax.servlet.jsp.tagext.TagLibraryInfo; import javax.xml.parsers.SAXParser; -import org.xml.sax.*; -import org.xml.sax.ext.LexicalHandler; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.AttributesImpl; +import javax.xml.parsers.SAXParserFactory; + import org.apache.jasper.JasperException; import org.apache.jasper.JspCompilationContext; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.XMLReader; +import org.xml.sax.ext.LexicalHandler; +import org.xml.sax.helpers.AttributesImpl; +import org.xml.sax.helpers.DefaultHandler; /** * Class implementing a parser for a JSP document, that is, a JSP page in XML @@ -81,19 +92,21 @@ * @author Jan Luehe */ -class JspDocumentParser extends DefaultHandler -implements LexicalHandler, TagConstants { +class JspDocumentParser +extends DefaultHandler +implements LexicalHandler, TagConstants { private static final String JSP_VERSION = version; -private static final String LEXICAL_HANDLER_PROPERTY - = http://xml.org/sax/properties/lexical-handler;; +private static final String LEXICAL_HANDLER_PROPERTY = +http://xml.org/sax/properties/lexical-handler;; -private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION -= new EnableDTDValidationException(jsp.error.enable_dtd_validation, - null); +private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION = +new EnableDTDValidationException( +jsp.error.enable_dtd_validation, +null); private ParserController parserController; -private JspCompilationContext ctxt; +private JspCompilationContext ctxt; private PageInfo pageInfo; private String path; @@ -115,11 +128,12 @@ /* * Constructor */ -public JspDocumentParser(ParserController pc, - String path, - JarFile jarFile, - boolean isTagFile, - boolean directivesOnly) { +public JspDocumentParser( +ParserController pc, +String path, +JarFile jarFile, +boolean isTagFile, +boolean directivesOnly) { this.parserController = pc; this.ctxt = pc.getJspCompilationContext(); this.pageInfo = pc.getCompiler().getPageInfo(); @@ -135,77 +149,82 @@ * * @throws JasperException */ -public static Node.Nodes parse(ParserController pc, -String path, -JarFile jarFile, -Node parent, -boolean isTagFile, -boolean directivesOnly, -String pageEnc, -String jspConfigPageEnc, -boolean isEncodingSpecifiedInProlog) - throws JasperException { - - JspDocumentParser jspDocParser = new JspDocumentParser(pc, - path, -jarFile, -
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java
luehe 2003/08/29 12:31:22 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java Log: Added support for JSP.6.2.4: A JSP document with a DOCTYPE declaration must be validated by the container in the translation phase. Validation errors must be handled the same way as any other translation phase errors, as described in Section JSP.1.4.1. JSP 2.0 requires only DTD validation for JSP documents; containers should not perform validation based on other types of schemas, such as XML schema. This fixes Bugtraq 4914702. Revision ChangesPath 1.68 +113 -39 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- JspDocumentParser.java25 Aug 2003 22:25:54 - 1.67 +++ JspDocumentParser.java29 Aug 2003 19:31:22 - 1.68 @@ -62,6 +62,7 @@ import java.io.*; import java.util.*; +import java.util.jar.JarFile; import javax.servlet.jsp.tagext.*; import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.ParserConfigurationException; @@ -87,24 +88,25 @@ private static final String LEXICAL_HANDLER_PROPERTY = http://xml.org/sax/properties/lexical-handler;; +private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION += new EnableDTDValidationException(jsp.error.enable_dtd_validation, + null); + private ParserController parserController; private JspCompilationContext ctxt; private PageInfo pageInfo; - -// XML document source -private InputSource inputSource; - private String path; // Node representing the XML element currently being parsed private Node current; -// Document locator private Locator locator; // Flag indicating whether we are inside DTD declarations private boolean inDTD; +private boolean isValidating; + private ErrorDispatcher err; private boolean isTagFile; private boolean directivesOnly; @@ -115,18 +117,17 @@ */ public JspDocumentParser(ParserController pc, String path, - InputStream inStream, + JarFile jarFile, boolean isTagFile, boolean directivesOnly) { - this.parserController = pc; - this.ctxt = pc.getJspCompilationContext(); - this.pageInfo = pc.getCompiler().getPageInfo(); - this.err = pc.getCompiler().getErrorDispatcher(); - this.path = path; - this.inputSource = new InputSource(inStream); - this.isTagFile = isTagFile; - this.directivesOnly = directivesOnly; - this.isTop = true; +this.parserController = pc; +this.ctxt = pc.getJspCompilationContext(); +this.pageInfo = pc.getCompiler().getPageInfo(); +this.err = pc.getCompiler().getErrorDispatcher(); +this.path = path; +this.isTagFile = isTagFile; +this.directivesOnly = directivesOnly; +this.isTop = true; } /* @@ -136,7 +137,7 @@ */ public static Node.Nodes parse(ParserController pc, String path, -InputStream inStream, +JarFile jarFile, Node parent, boolean isTagFile, boolean directivesOnly, @@ -145,8 +146,9 @@ boolean isEncodingSpecifiedInProlog) throws JasperException { - JspDocumentParser jspDocParser = new JspDocumentParser(pc, path, -inStream, + JspDocumentParser jspDocParser = new JspDocumentParser(pc, + path, +jarFile, isTagFile, directivesOnly); Node.Nodes pageNodes = null; @@ -166,21 +168,25 @@ jspDocParser.isTop = false; } - // Use the default (non-validating) parser - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - // Preserve xmlns attributes -
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ErrorDispatcher.java
kinman 2003/08/21 16:10:50 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ErrorDispatcher.java Log: - Looks like when there is a SAX paser error, a null file name is always reported. This fix get the file name from path instead of from the expection. Revision ChangesPath 1.66 +7 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- JspDocumentParser.java15 Aug 2003 00:06:09 - 1.65 +++ JspDocumentParser.java21 Aug 2003 23:10:49 - 1.66 @@ -193,7 +193,10 @@ } catch (IOException ioe) { jspDocParser.err.jspError(jsp.error.data.file.read, path, ioe); } catch (Exception e) { - jspDocParser.err.jspError(e); + jspDocParser.err.jspError( + new Mark(path, ((SAXParseException) e).getLineNumber(), + ((SAXParseException) e).getColumnNumber()), + e.getMessage()); } return pageNodes; 1.14 +3 -8 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ErrorDispatcher.java Index: ErrorDispatcher.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ErrorDispatcher.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ErrorDispatcher.java 14 Aug 2003 21:16:52 - 1.13 +++ ErrorDispatcher.java 21 Aug 2003 23:10:49 - 1.14 @@ -386,11 +386,6 @@ line = where.getLineNumber(); column = where.getColumnNumber(); hasLocation = true; - } else if (e instanceof SAXParseException) { - file = ((SAXParseException) e).getSystemId(); - line = ((SAXParseException) e).getLineNumber(); - column = ((SAXParseException) e).getColumnNumber(); - hasLocation = true; } // Get nested exception - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
remm2003/08/09 07:55:46 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: - pop is called in the same order as push, so using a stack is not correct. A linked list should be used instead. Revision ChangesPath 1.63 +9 -10 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- JspDocumentParser.java8 Aug 2003 22:22:09 - 1.62 +++ JspDocumentParser.java9 Aug 2003 14:55:46 - 1.63 @@ -109,7 +109,7 @@ private boolean isTagFile; private boolean directivesOnly; private boolean isTop; -private Stack prefixMapStack; +private LinkedList prefixMapLinkedList; /* * Constructor @@ -128,7 +128,7 @@ this.isTagFile = isTagFile; this.directivesOnly = directivesOnly; this.isTop = true; -this.prefixMapStack = new Stack();; +this.prefixMapLinkedList = new LinkedList();; } /* @@ -560,10 +560,9 @@ if (taglibInfo != null) { pageInfo.addTaglib(uri, taglibInfo); pageInfo.pushPrefixMapping(prefix, uri); -prefixMapStack.push(new Boolean(true)); - } -else { -prefixMapStack.push(new Boolean(false)); +prefixMapLinkedList.addLast(new Boolean(true)); +} else { +prefixMapLinkedList.addLast(new Boolean(false)); } } @@ -571,7 +570,7 @@ * Receives notification of the end of a Namespace mapping. */ public void endPrefixMapping(String prefix) throws SAXException { -if (((Boolean)prefixMapStack.pop()).booleanValue()) { +if (((Boolean) prefixMapLinkedList.removeFirst()).booleanValue()) { pageInfo.popPrefixMapping(prefix); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageInfo.java
kinman 2003/08/08 15:22:10 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageInfo.java Log: - Refactor some code in JspDocumentParser, since startPrefixMapping got called before startElement. - Turn on push/pop prefixes for taglibs in XML syntax, so that proper prefix can be located. - Fix a minor bug in PageInfo. Revision ChangesPath 1.62 +31 -30 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- JspDocumentParser.java21 Jul 2003 21:52:51 - 1.61 +++ JspDocumentParser.java8 Aug 2003 22:22:09 - 1.62 @@ -109,6 +109,7 @@ private boolean isTagFile; private boolean directivesOnly; private boolean isTop; +private Stack prefixMapStack; /* * Constructor @@ -127,6 +128,7 @@ this.isTagFile = isTagFile; this.directivesOnly = directivesOnly; this.isTop = true; +this.prefixMapStack = new Stack();; } /* @@ -265,20 +267,9 @@ isTaglib = true; } else { String attrUri = attrs.getValue(i); - if (!pageInfo.hasTaglib(attrUri)) { - TagLibraryInfo tagLibInfo = null; - try { - tagLibInfo = getTaglibInfo(attrQName, attrUri); - } catch (JasperException je) { - throw new SAXParseException( - Localizer.getMessage(jsp.error.could.not.add.taglibraries), - locator, je); - } - if (tagLibInfo != null) { - isTaglib = true; - } - pageInfo.addTaglib(attrUri, tagLibInfo); - } + // TaglibInfo for this uri already established in + // startPrefixMapping + isTaglib = pageInfo.hasTaglib(attrUri); } if (isTaglib) { if (taglibAttrs == null) { @@ -555,16 +546,34 @@ /* * Receives notification of the start of a Namespace mapping. */ - public void startPrefixMapping(String prefix, String uri) +public void startPrefixMapping(String prefix, String uri) throws SAXException { - // XXX +TagLibraryInfo taglibInfo; +try { +taglibInfo = getTaglibInfo(prefix, uri); +} catch (JasperException je) { +throw new SAXParseException( +Localizer.getMessage(jsp.error.could.not.add.taglibraries), +locator, je); +} + +if (taglibInfo != null) { +pageInfo.addTaglib(uri, taglibInfo); +pageInfo.pushPrefixMapping(prefix, uri); +prefixMapStack.push(new Boolean(true)); + } +else { +prefixMapStack.push(new Boolean(false)); +} } /* * Receives notification of the end of a Namespace mapping. */ public void endPrefixMapping(String prefix) throws SAXException { - // XXX +if (((Boolean)prefixMapStack.pop()).booleanValue()) { +pageInfo.popPrefixMapping(prefix); +} } @@ -792,23 +801,15 @@ * Creates the tag library associated with the given uri namespace, and * returns it. * - * @param qName The qualified name of the xmlns attribute - * (of the form 'xmlns:prefix') + * @param prefix The prefix of the xmlns attribute * @param uri The uri namespace (value of the xmlns attribute) * * @return The tag library associated with the given uri namespace */ -private TagLibraryInfo getTaglibInfo(String qName, String uri) +private TagLibraryInfo getTaglibInfo(String prefix, String uri) throws JasperException { TagLibraryInfo result = null; - - // Get the prefix - String prefix = ; - int colon = qName.indexOf(':'); - if (colon != -1) { - prefix = qName.substring(colon + 1); - } if (uri.startsWith(URN_JSPTAGDIR)) { // uri (of the form urn:jsptagdir:path) references tag file dir 1.38 +4 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageInfo.java Index: PageInfo.java
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageInfo.java Parser.java TldLocationsCache.java Validator.java
luehe 2003/03/31 11:15:34 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageInfo.java Parser.java TldLocationsCache.java Validator.java Log: Fixed 18236 (An xmlns declaration that doesn't denote a tag library causes translation error) Revision ChangesPath 1.50 +15 -8 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- JspDocumentParser.java28 Mar 2003 02:13:02 - 1.49 +++ JspDocumentParser.java31 Mar 2003 19:15:34 - 1.50 @@ -104,7 +104,7 @@ // Document locator private Locator locator; -private Hashtable taglibs; +private HashMap taglibs; // Flag indicating whether we are inside DTD declarations private boolean inDTD; @@ -773,16 +773,23 @@ tagdir, err); } else { // uri references TLD file + boolean isPlainUri = false; if (uri.startsWith(URN_JSPTLD)) { // uri is of the form urn:jsptld:path uri = uri.substring(URN_JSPTLD.length()); + } else { + isPlainUri = true; } TldLocationsCache cache = ctxt.getOptions().getTldLocationsCache(); - result = cache.getTagLibraryInfo(uri); - if (result == null) { - // get the location - String[] location = ctxt.getTldLocation(uri); + String[] location = cache.getLocation(uri); + if (location != null || !isPlainUri) { + /* + * If the uri value is a plain uri, a translation error must + * not be generated if the uri is not found in the taglib map. + * Instead, any actions in the namespace defined by the uri + * value must be treated as uninterpreted. + */ result = new TagLibraryInfoImpl(ctxt, parserController, prefix, uri, location, err); } 1.28 +7 -7 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.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- PageInfo.java 25 Mar 2003 00:57:46 - 1.27 +++ PageInfo.java 31 Mar 2003 19:15:34 - 1.28 @@ -76,7 +76,7 @@ private Vector dependants; private BeanRepository beanRepository; -private Hashtable tagLibraries; +private HashMap taglibsMap; private Hashtable prefixMapper; private String language = java; @@ -113,7 +113,7 @@ PageInfo(BeanRepository beanRepository) { this.beanRepository = beanRepository; - this.tagLibraries = new Hashtable(); + this.taglibsMap = new HashMap(); this.prefixMapper = new Hashtable(); this.imports = new Vector(); this.dependants = new Vector(); @@ -163,8 +163,8 @@ return beanRepository; } -public Hashtable getTagLibraries() { - return tagLibraries; +public HashMap getTagLibraries() { + return taglibsMap; } /* 1.71 +5 -4 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.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- Parser.java 28 Mar 2003 02:13:02 - 1.70 +++ Parser.java 31 Mar 2003 19:15:34 - 1.71 @@ -63,6 +63,7 @@ import java.io.FileNotFoundException; import java.io.CharArrayWriter; import java.util.Hashtable; +import java.util.HashMap; import java.util.List; import java.util.Iterator; import java.util.jar.JarFile; @@ -94,7 +95,7 @@ private JspReader reader; private String currentFile; private Mark start; -private Hashtable taglibs; +private HashMap taglibs; private Hashtable prefixMapper; private ErrorDispatcher err; private int scriptlessCount; 1.15 +18 -29 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TldLocationsCache.java Index: TldLocationsCache.java
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java PageInfo.java ParserController.java Validator.java
luehe 2003/03/24 16:57:46 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java PageInfo.java ParserController.java Validator.java Log: Moved indication of whether XML prolog contains explicit encoding declaration from PageInfo (per translation unit) to Node.Root (per file). Revision ChangesPath 1.48 +6 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- JspDocumentParser.java24 Mar 2003 21:36:05 - 1.47 +++ JspDocumentParser.java25 Mar 2003 00:57:46 - 1.48 @@ -146,7 +146,8 @@ boolean isTagFile, boolean directivesOnly, String pageEnc, -String jspConfigPageEnc) +String jspConfigPageEnc, +boolean isEncodingSpecifiedInProlog) throws JasperException { JspDocumentParser jspDocParser = new JspDocumentParser(pc, path, @@ -173,6 +174,7 @@ Node.Root dummyRoot = new Node.Root(null, parent, true); dummyRoot.setPageEncoding(pageEnc); dummyRoot.setJspConfigPageEncoding(jspConfigPageEnc); + dummyRoot.setIsEncodingSpecifiedInProlog(isEncodingSpecifiedInProlog); jspDocParser.current = dummyRoot; if (parent != null) { 1.68 +19 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java Index: Node.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- Node.java 24 Mar 2003 21:36:05 - 1.67 +++ Node.java 25 Mar 2003 00:57:46 - 1.68 @@ -396,6 +396,14 @@ private String jspConfigPageEnc; /* + * Indicates whether an encoding has been explicitly specified in the + * page's XML prolog (only used for pages in XML syntax). + * This information is used to decide whether a translation error must + * be reported for encoding conflicts. + */ + private boolean isEncodingSpecifiedInProlog; + + /* * Constructor. */ Root(Mark start, Node parent, boolean isXmlSyntax) { @@ -441,6 +449,14 @@ public String getPageEncoding() { return pageEnc; + } + + public void setIsEncodingSpecifiedInProlog(boolean isSpecified) { + isEncodingSpecifiedInProlog = isSpecified; + } + + public boolean isEncodingSpecifiedInProlog() { + return isEncodingSpecifiedInProlog; } /** 1.27 +3 -19 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.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- PageInfo.java 24 Mar 2003 21:36:05 - 1.26 +++ PageInfo.java 25 Mar 2003 00:57:46 - 1.27 @@ -89,14 +89,6 @@ private boolean isErrorPage = false; private String errorPage = null; -/* - * Indicates whether an encoding has been explicitly specified in the - * page's XML prolog (only used for pages in XML syntax). - * This information is used to decide whether a translation error must - * be reported for encoding conflicts. - */ -private boolean isEncodingSpecifiedInProlog; - private int maxTagNesting = 0; private boolean scriptless = false; private boolean scriptingInvalid = false; @@ -252,14 +244,6 @@ public void setIsErrorPage(boolean isErrorPage) { this.isErrorPage = isErrorPage; -} - -public void setIsEncodingSpecifiedInProlog(boolean isSpecified) { - this.isEncodingSpecifiedInProlog = isSpecified; -} - -public boolean isEncodingSpecifiedInProlog() { - return this.isEncodingSpecifiedInProlog; } public int getMaxTagNesting() { 1.36 +20 -18 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java Index: ParserController.java === RCS file:
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java PageDataImpl.java
luehe 2003/02/19 15:39:16 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java PageDataImpl.java Log: Preserve xmlns:prefix attributes in XML view. This also fixes 17204: jsp:element generates incorrect output when used in a JSP Document and the element includes an xmlns attribute Revision ChangesPath 1.39 +158 -113 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- JspDocumentParser.java13 Feb 2003 02:41:26 - 1.38 +++ JspDocumentParser.java19 Feb 2003 23:39:15 - 1.39 @@ -169,7 +169,7 @@ // create dummy jsp:root element AttributesImpl rootAttrs = new AttributesImpl(); rootAttrs.addAttribute(, , version, CDATA, 2.0); - jspRoot = new Node.JspRoot(rootAttrs, null, null); + jspRoot = new Node.JspRoot(rootAttrs, null, null, null); handler.current = jspRoot; } else { handler.isTop = false; @@ -228,24 +228,33 @@ // is valid from that point forward. Redefinitions cause an // error. This isn't quite consistent with how xmlns: normally // works. - Attributes attrsCopy = null; - try { - attrsCopy = addCustomTagLibraries(attrs); - } catch (JasperException je) { - throw new SAXParseException( -Localizer.getMessage(jsp.error.could.not.add.taglibraries), - locator, je ); + AttributesImpl attrsCopy = null; + Attributes xmlnsAttrs = null; + if (attrs != null) { + attrsCopy = new AttributesImpl(attrs); + xmlnsAttrs = getXmlnsAttributes(attrsCopy); + if (xmlnsAttrs != null) { + try { + addCustomTagLibraries(xmlnsAttrs); + } catch (JasperException je) { + throw new SAXParseException( + Localizer.getMessage( +jsp.error.could.not.add.taglibraries), + locator, je); + } + } } Node node = null; if (qName.startsWith(jsp:)) { - node = parseStandardAction(qName, attrs, attrsCopy, start, + node = parseStandardAction(qName, attrsCopy, xmlnsAttrs, start, current); } else { - node = parseCustomAction(qName, attrsCopy, start, current); + node = parseCustomAction(qName, attrsCopy, xmlnsAttrs, start, + current); if (node == null) { - node = new Node.UninterpretedTag(attrsCopy, start, qName, - current); + node = new Node.UninterpretedTag(qName, attrsCopy, xmlnsAttrs, + start, current); } } @@ -483,7 +492,7 @@ // Private utility methods private Node parseStandardAction(String qName, Attributes attrs, - Attributes attrsCopy, Mark start, + Attributes xmlnsAttrs, Mark start, Node parent) throws SAXException { @@ -493,7 +502,7 @@ // give the jsp:root element the original attributes set // (attrs) instead of the copy without the xmlns: elements // (attrsCopy) - node = new Node.JspRoot(new AttributesImpl(attrs), start, current); + node = new Node.JspRoot(attrs, xmlnsAttrs, start, current); if (isTop) { pageInfo.setHasJspRoot(true); } @@ -503,45 +512,46 @@ Localizer.getMessage(jsp.error.action.istagfile, qName), locator); } - node = new Node.PageDirective(attrsCopy, start, current); + node = new Node.PageDirective(attrs, xmlnsAttrs, start, current); String imports = attrs.getValue(import); // There can only be one 'import' attribute per page directive if (imports != null) { ((Node.PageDirective) node).addImport(imports); } } else if (qName.equals(JSP_INCLUDE_DIRECTIVE)) { - node = new Node.IncludeDirective(attrsCopy, start, current); - processIncludeDirective(attrsCopy.getValue(file), node); + node = new Node.IncludeDirective(attrs, xmlnsAttrs, start, + current); +
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java PageDataImpl.java Parser.java
luehe 2003/02/19 17:02:52 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java PageDataImpl.java Parser.java Log: - When adding a jsp:root element to the XML view of a JSP document, do not populate it with an xmlns:jsp=... attribute (add this attribute only to the jsp:root element of the XML view of a JSP page in *standard* syntax). - Added support for jsp:element to XML view Revision ChangesPath 1.40 +5 -7 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- JspDocumentParser.java19 Feb 2003 23:39:15 - 1.39 +++ JspDocumentParser.java20 Feb 2003 01:02:51 - 1.40 @@ -162,14 +162,12 @@ } Node.Nodes pageNodes = null; - Node.JspRoot jspRoot = null; + Node.Root jspRoot = null; try { if (parent == null) { // create dummy jsp:root element - AttributesImpl rootAttrs = new AttributesImpl(); - rootAttrs.addAttribute(, , version, CDATA, 2.0); - jspRoot = new Node.JspRoot(rootAttrs, null, null, null); + jspRoot = new Node.Root(); handler.current = jspRoot; } else { handler.isTop = false; 1.58 +16 -7 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java Index: Node.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- Node.java 19 Feb 2003 23:39:15 - 1.57 +++ Node.java 20 Feb 2003 01:02:51 - 1.58 @@ -343,8 +343,16 @@ private Root parentRoot; - Root(Attributes attrs, Mark start, Node parent) { - super(attrs, start, parent); + /* + * Constructor for dummy root. + */ + Root() {} + + /* + * Constructor. + */ + Root(Mark start, Node parent) { + super(start, parent); // Figure out and set the parent root Node r = parent; @@ -362,7 +370,7 @@ } /** - * @return The enclosing root to this root. Usually represents the + * @return The enclosing root to this root. Usually represents the * page that includes this one. */ public Root getParentRoot() { @@ -377,7 +385,8 @@ public JspRoot(Attributes attrs, Attributes xmlnsAttrs, Mark start, Node parent) { - super(attrs, start, parent); + super(start, parent); + this.attrs = attrs; this.xmlnsAttrs = xmlnsAttrs; } 1.22 +42 -43 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java Index: PageDataImpl.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- PageDataImpl.java 19 Feb 2003 23:39:15 - 1.21 +++ PageDataImpl.java 20 Feb 2003 01:02:51 - 1.22 @@ -97,24 +97,9 @@ private static final String CDATA_START_SECTION = ![CDATA[\n; private static final String CDATA_END_SECTION = ]]\n; -// default xmlns:jsp and version attributes of jsp:root element -private static AttributesImpl defaultJspRootAttrs; - // string buffer used to build XML view private StringBuffer buf; -/* - * Static initializer which sets the xmlns:jsp and version - * attributes of the jsp:root element to their default values. - */ -static { - defaultJspRootAttrs = new AttributesImpl(); - defaultJspRootAttrs.addAttribute(, , xmlns:jsp, CDATA, - JSP_NAMESPACE); - defaultJspRootAttrs.addAttribute(, , version, CDATA, - JSP_VERSION); -} - /** * Constructor. * @@ -124,15 +109,16 @@ throws JasperException { // First pass - FirstPassVisitor firstPassVisitor - = new FirstPassVisitor(page.getRoot()); - page.visit(firstPassVisitor); + boolean isXml = compiler.getPageInfo().isXml(); + FirstPassVisitor firstPass = new FirstPassVisitor(page.getRoot(), +
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java
luehe 2002/11/27 08:42:26 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java Log: Applied patch provided by Ryan Lubke to fix encoding issue: When processing a JSP document, pass the document's raw input stream to the SAX parser, that is, do not apply the autodetected encoding to it (the SAX parser will figure out the encoding itself). Revision ChangesPath 1.30 +7 -7 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- JspDocumentParser.java11 Nov 2002 19:26:28 - 1.29 +++ JspDocumentParser.java27 Nov 2002 16:42:26 - 1.30 @@ -119,7 +119,7 @@ */ public JspDocumentParser(ParserController pc, String path, - InputStreamReader reader, + InputStream inStream, boolean isTagFile, boolean directivesOnly) { this.parserController = pc; @@ -128,7 +128,7 @@ this.taglibs = this.pageInfo.getTagLibraries(); this.err = pc.getCompiler().getErrorDispatcher(); this.path = path; - this.inputSource = new InputSource(reader); + this.inputSource = new InputSource(inStream); this.isTagFile = isTagFile; this.directivesOnly = directivesOnly; this.isTop = true; @@ -141,13 +141,13 @@ */ public static Node.Nodes parse(ParserController pc, String path, -InputStreamReader reader, +InputStream inStream, Node parent, boolean isTagFile, boolean directivesOnly) throws JasperException { - JspDocumentParser handler = new JspDocumentParser(pc, path, reader, + JspDocumentParser handler = new JspDocumentParser(pc, path, inStream, isTagFile, directivesOnly); Node.Nodes pageNodes = null; 1.27 +43 -29 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.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- ParserController.java 7 Nov 2002 22:19:13 - 1.26 +++ ParserController.java 27 Nov 2002 16:42:26 - 1.27 @@ -180,46 +180,60 @@ throws FileNotFoundException, JasperException, IOException { Node.Nodes parsedPage = null; -InputStreamReader reader = null; String absFileName = resolveFileName(inFileName); JarFile jarFile = (JarFile) ctxt.getTagFileJars().get(inFileName); -try { -// Figure out what type of JSP document and encoding type we are - // dealing with -String encoding = figureOutJspDocument(absFileName, jarFile); + // Figure out what type of JSP document and encoding type we are + // dealing with + String encoding = figureOutJspDocument(absFileName, jarFile); - if (isTopFile) { - pageInfo.setIsXml(isXml); - isTopFile = false; - } else { - compiler.getPageInfo().addDependant(absFileName); - } + if (isTopFile) { + pageInfo.setIsXml(isXml); + isTopFile = false; + } else { + compiler.getPageInfo().addDependant(absFileName); + } -// dispatch to the proper parser -reader = JspUtil.getReader(absFileName, encoding, jarFile, ctxt, -err); -if (isXml) { -parsedPage = JspDocumentParser.parse(this, absFileName, - reader, parent, + // Dispatch to the proper parser + if (isXml) { + InputStream inStream = null; + try { + inStream = JspUtil.getInputStream(absFileName, jarFile, ctxt, + err); + parsedPage = JspDocumentParser.parse(this, absFileName, + inStream, parent,
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
luehe 2002/11/11 11:26:29 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Fixed 14413: NPE while using jsp:attribute in JSP Document Revision ChangesPath 1.29 +22 -15 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- JspDocumentParser.java8 Nov 2002 19:55:47 - 1.28 +++ JspDocumentParser.java11 Nov 2002 19:26:28 - 1.29 -435,19 +435,26 return; } - if (current instanceof Node.NamedAttribute - ((Node.NamedAttribute) current).isTrim()) { - // Ignore any whitespace (including spaces, carriage returns, - // line feeds, and tabs, that appear at the beginning and at the - // end of the body of the jsp:attribute action. + if (current instanceof Node.NamedAttribute) { Node.Nodes subelems = ((Node.NamedAttribute) current).getBody(); - Node firstNode = subelems.getNode(0); - if (firstNode instanceof Node.TemplateText) { - ((Node.TemplateText) firstNode).ltrim(); + if (subelems == null) { +throw new SAXParseException( + err.getString(jsp.error.empty.body.not.allowed, + lt;jsp:attribute), + locator); } - Node lastNode = subelems.getNode(subelems.size() - 1); - if (lastNode instanceof Node.TemplateText) { - ((Node.TemplateText) lastNode).rtrim(); + if (((Node.NamedAttribute) current).isTrim()) { + // Ignore any whitespace (including spaces, carriage returns, + // line feeds, and tabs, that appear at the beginning and at + // the end of the body of the jsp:attribute action. + Node firstNode = subelems.getNode(0); + if (firstNode instanceof Node.TemplateText) { + ((Node.TemplateText) firstNode).ltrim(); + } + Node lastNode = subelems.getNode(subelems.size() - 1); + if (lastNode instanceof Node.TemplateText) { + ((Node.TemplateText) lastNode).rtrim(); + } } } else if (current instanceof Node.ScriptingElement) { checkScriptingBody((Node.ScriptingElement) current); -- To unsubscribe, e-mail: mailto:tomcat-dev-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-dev-help;jakarta.apache.org
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
luehe 2002/11/07 15:52:07 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Fixed 12414: Tag file defined in XML syntax does not seem to recognize import attribute in tag directive Revision ChangesPath 1.25 +8 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- JspDocumentParser.java1 Nov 2002 02:54:41 - 1.24 +++ JspDocumentParser.java7 Nov 2002 23:52:07 - 1.25 -284,6 +284,11 locator); } node = new Node.TagDirective(attrsCopy, start, current); + String imports = attrs.getValue(import); + // There can only be one 'import' attribute per tag directive + if (imports != null) { + ((Node.TagDirective) node).addImport(imports); + } } else if (qName.equals(JSP_ATTRIBUTE_DIRECTIVE)) { if (!isTagFile) { throw new SAXParseException( -- To unsubscribe, e-mail: mailto:tomcat-dev-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-dev-help;jakarta.apache.org
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageDataImpl.java
kinman 2002/11/07 19:03:01 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageDataImpl.java Log: - Parse EL expressions in JSP page(in XML syntax). - Output EL expressions in XML view. Revision ChangesPath 1.26 +63 -6 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- JspDocumentParser.java7 Nov 2002 23:52:07 - 1.25 +++ JspDocumentParser.java8 Nov 2002 03:03:01 - 1.26 -359,9 +359,66 if ((current instanceof Node.JspText) || !isAllSpace) { Mark start = new Mark(path, locator.getLineNumber(), locator.getColumnNumber()); - char[] bufCopy = new char[len]; - System.arraycopy(buf, offset, bufCopy, 0, len); - new Node.TemplateText(bufCopy, start, current); + + CharArrayWriter ttext = new CharArrayWriter(); + int limit = offset + len; + int lastCh = 0; + for (int i = offset; i limit; i++) { + int ch = buf[i]; + if (lastCh == '$' ch == '{') { + char[] bufCopy = ttext.toCharArray(); + if (bufCopy.length 0) { + new Node.TemplateText(bufCopy, start, current); + ttext = new CharArrayWriter(); + } + // following ${ to first unquoted } + i++; + boolean singleQ = false; + boolean doubleQ = false; + lastCh = 0; + for (; ; i++) { + if (i = limit) { + throw new SAXParseException( + err.getString(jsp.error.unterminated, ${), + locator); + + } + ch = buf[i]; + if (lastCh == '\\' (singleQ || doubleQ)) { + ttext.write(ch); + lastCh = 0; + continue; + } + if (ch == '}') { + new Node.ELExpression(ttext.toCharArray(), start, current); + ttext = new CharArrayWriter(); + break; + } + if (ch == '') + doubleQ = !doubleQ; + else if (ch == '\'') + singleQ = !singleQ; + + ttext.write(ch); + lastCh = ch; + } + } else { + if( (lastCh == '$') (ch != '{') ) { +ttext.write( '$' ); +} +if( ch != '$' ) { +ttext.write( ch ); +} +} +lastCh = ch; + } + if (lastCh == '$') { + ttext.write('$'); + } + char[] bufCopy = ttext.toCharArray(); + if (bufCopy.length 0) { + new Node.TemplateText(bufCopy, start, current); + } } } 1.18 +18 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java Index: PageDataImpl.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- PageDataImpl.java 7 Nov 2002 18:34:19 - 1.17 +++ PageDataImpl.java 8 Nov 2002 03:03:01 - 1.18 -306,6 +306,21 appendTag(JSP_SCRIPTLET, n.getAttributes(), null, n.getText()); } + public void visit(Node.ELExpression n) throws JasperException { + if (!n.isXmlSyntax()) { + buf.append().append(JSP_TEXT); + buf.append( jsp:id=\); + buf.append(jspId++).append(\); + } + buf.append(${); + buf.append(n.getText()); + buf.append(}); + if (!n.isXmlSyntax()) { + buf.append(JSP_TEXT_END); + } + buf.append(\n); + } + public void visit(Node.IncludeAction n) throws JasperException { appendTag(JSP_INCLUDE, n.getAttributes(), n.getBody(), null); } -- To unsubscribe, e-mail: mailto:tomcat-dev-unsubscribe;jakarta.apache.org For additional commands, e-mail:
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageDataImpl.java TagConstants.java
luehe 2002/10/30 10:20:21 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageDataImpl.java TagConstants.java Log: Added urn:jsptagdir:path to XML view of JSP pages in JSP syntax Revision ChangesPath 1.23 +6 -8 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- JspDocumentParser.java28 Oct 2002 23:21:08 - 1.22 +++ JspDocumentParser.java30 Oct 2002 18:20:21 - 1.23 -86,8 +86,6 private static final String XMLNS = xmlns:; private static final String XMLNS_JSP = xmlns:jsp; private static final String JSP_VERSION = version; -private static final String URN_JSPTLD = urn:jsptld:; -private static final String URN_JSPTAGDIR = urn:jsptagdir:; private static final String LEXICAL_HANDLER_PROPERTY = http://xml.org/sax/properties/lexical-handler;; -619,11 +617,11 for (int i=0; isize; i++) { Node n = body.getNode(i); if (!(n instanceof Node.TemplateText)) { - String elemType = TagConstants.JSP_SCRIPTLET; + String elemType = JSP_SCRIPTLET; if (scriptingElem instanceof Node.Declaration) - elemType = TagConstants.JSP_DECLARATION; + elemType = JSP_DECLARATION; if (scriptingElem instanceof Node.Expression) - elemType = TagConstants.JSP_EXPRESSION; + elemType = JSP_EXPRESSION; String msg = err.getString( jsp.error.parse.xml.scripting.invalid.body, elemType); 1.14 +13 -10 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java Index: PageDataImpl.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- PageDataImpl.java 28 Oct 2002 20:48:01 - 1.13 +++ PageDataImpl.java 30 Oct 2002 18:20:21 - 1.14 -159,7 +159,8 * In addition, this Visitor converts any taglib directives into xmlns: * attributes and adds them to the jsp:root element of the XML view. */ -static class FirstPassVisitor extends Node.Visitor { +static class FirstPassVisitor + extends Node.Visitor implements TagConstants { private Node.Root root; private AttributesImpl rootAttrs; -206,19 +207,21 } /* - * Converts taglib directive into xmlns: attribute of jsp:root element. + * Converts taglib directive into xmlns:... attribute of jsp:root + * element. */ public void visit(Node.TaglibDirective n) throws JasperException { Attributes attrs = n.getAttributes(); if (attrs != null) { + String type = xmlns: + attrs.getValue(prefix); String location = attrs.getValue(uri); - if (location == null) { - // XXX JSP 2.0 CLARIFICATION NEEDED + if (location != null) { + rootAttrs.addAttribute(, , type, CDATA, location); + } else { location = attrs.getValue(tagdir); + rootAttrs.addAttribute(, , type, CDATA, +URN_JSPTAGDIR + location); } - String prefix = attrs.getValue(prefix); - rootAttrs.addAttribute(, , xmlns: + prefix, CDATA, -location); } } } 1.7 +9 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagConstants.java Index: TagConstants.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagConstants.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- TagConstants.java 28 Oct 2002 23:21:08 - 1.6 +++ TagConstants.java 30 Oct 2002 18:20:21 - 1.7 -107,4 +107,10 = jsp:directive.attribute; public static final String JSP_VARIABLE_DIRECTIVE = jsp:directive.variable; + +/* + * Directive attributes + */ +public static final String URN_JSPTAGDIR = urn:jsptagdir:; +public static final
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
luehe 2002/10/28 11:25:47 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Added support for URIs of the form: urn:jsptagdir:path Revision ChangesPath 1.21 +50 -25 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- JspDocumentParser.java22 Oct 2002 03:00:20 - 1.20 +++ JspDocumentParser.java28 Oct 2002 19:25:47 - 1.21 -87,6 +87,7 private static final String XMLNS_JSP = xmlns:jsp; private static final String JSP_VERSION = version; private static final String URN_JSPTLD = urn:jsptld:; +private static final String URN_JSPTAGDIR = urn:jsptagdir:; private static final String LEXICAL_HANDLER_PROPERTY = http://xml.org/sax/properties/lexical-handler;; -505,7 +506,8 } return new Node.CustomTag(attrs, start, qName, prefix, shortName, - tagInfo, tagFileInfo, tagHandlerClass, parent); + tagInfo, tagFileInfo, tagHandlerClass, + parent); } /* -533,35 +535,58 continue; } - // get the uri - String uri = attrs.getValue(i); - if (uri.startsWith(URN_JSPTLD)) { - // uri value is of the form urn:jsptld:path - uri = uri.substring(URN_JSPTLD.length()); - } - -TldLocationsCache cache - = ctxt.getOptions().getTldLocationsCache(); -TagLibraryInfo tl = cache.getTagLibraryInfo(uri); -if (tl == null) { -// get the location -String[] location = ctxt.getTldLocation(uri); - -tl = new TagLibraryInfoImpl(ctxt, parserController, prefix, - uri, location, err); -} if( taglibs.containsKey( prefix ) ) { // Prefix already in taglib map. throw new JasperException( err.getString( jsp.error.xmlns.redefinition.notimplemented, prefix ) ); } -else { -taglibs.put(prefix, tl); -result.removeAttribute( i ); -} + + // get the uri + String uri = attrs.getValue(i); + + TagLibraryInfo tagLibInfo = null; + if (uri.startsWith(URN_JSPTAGDIR)) { + /* + * uri references tag file directory + * (is of the form urn:jsptagdir:path) + */ + String tagdir = uri.substring(URN_JSPTAGDIR.length()); + tagLibInfo = new ImplicitTagLibraryInfo(ctxt, + parserController, + prefix, + tagdir, + err); + } else { + /* + * uri references TLD file + */ + if (uri.startsWith(URN_JSPTLD)) { + // uri is of the form urn:jsptld:path + uri = uri.substring(URN_JSPTLD.length()); + } + + TldLocationsCache cache + = ctxt.getOptions().getTldLocationsCache(); + tagLibInfo = cache.getTagLibraryInfo(uri); + if (tagLibInfo == null) { + // get the location + String[] location = ctxt.getTldLocation(uri); + + tagLibInfo = new TagLibraryInfoImpl(ctxt, + parserController, + prefix, + uri, + location, + err); + } + } + + taglibs.put(prefix, tagLibInfo); + result.removeAttribute( i ); } } + return result; } -- To unsubscribe, e-mail:
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java TagConstants.java
luehe 2002/10/28 15:21:08 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ParserController.java TagConstants.java Log: Added support for tag files in XML syntax Revision ChangesPath 1.22 +34 -21 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- JspDocumentParser.java28 Oct 2002 19:25:47 - 1.21 +++ JspDocumentParser.java28 Oct 2002 23:21:08 - 1.22 -113,6 +113,7 private ErrorDispatcher err; private boolean isTagFile; +private boolean directivesOnly; /* * Constructor -120,7 +121,8 public JspDocumentParser(ParserController pc, String path, InputStreamReader reader, - boolean isTagFile) { + boolean isTagFile, + boolean directivesOnly) { this.parserController = pc; this.ctxt = pc.getJspCompilationContext(); this.pageInfo = pc.getCompiler().getPageInfo(); -129,6 +131,7 this.path = path; this.inputSource = new InputSource(reader); this.isTagFile = isTagFile; + this.directivesOnly = directivesOnly; } /* -140,10 +143,13 String path, InputStreamReader reader, Node parent, -boolean isTagFile) throws JasperException { +boolean isTagFile, +boolean directivesOnly) + throws JasperException { JspDocumentParser handler = new JspDocumentParser(pc, path, reader, - isTagFile); + isTagFile, + directivesOnly); Node.Nodes pageNodes = null; Node.JspRoot jspRoot = null; -196,24 +202,28 String qName, Attributes attrs) throws SAXException { + if (directivesOnly !qName.startsWith(JSP_DIRECTIVE)) { + return; + } + Mark start = new Mark(path, locator.getLineNumber(), locator.getColumnNumber()); - Attributes attrsCopy; + Attributes attrsCopy = null; Node node = null; -// XXX - As of JSP 2.0, xmlns: can appear in any node (not just -// jsp:root). The spec still needs clarification here. -// What we implement is that it can appear in any node and -// is valid from that point forward. Redefinitions cause an -// error. This isn't quite consistent with how xmlns: normally -// works. -try { -attrsCopy = addCustomTagLibraries(attrs); -} catch (JasperException je) { -throw new SAXParseException( err.getString( + // XXX - As of JSP 2.0, xmlns: can appear in any node (not just + // jsp:root). The spec still needs clarification here. + // What we implement is that it can appear in any node and + // is valid from that point forward. Redefinitions cause an + // error. This isn't quite consistent with how xmlns: normally + // works. + try { + attrsCopy = addCustomTagLibraries(attrs); + } catch (JasperException je) { + throw new SAXParseException( err.getString( jsp.error.could.not.add.taglibraries ), locator, je ); -} + } if (qName.equals(JSP_ROOT)) { // give the jsp:root element the original attributes set -352,6 +362,11 public void endElement(String uri, String localName, String qName) throws SAXException { + + if (directivesOnly !qName.startsWith(JSP_DIRECTIVE)) { + return; + } + if (current instanceof Node.NamedAttribute ((Node.NamedAttribute) current).isTrim()) { // Ignore any whitespace (including spaces, carriage returns, -366,9 +381,7 if (lastNode instanceof Node.TemplateText) { ((Node.TemplateText) lastNode).rtrim(); } - } - - if (current instanceof Node.ScriptingElement) { + } else if (current instanceof Node.ScriptingElement) { checkScriptingBody((Node.ScriptingElement) current);
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java SmapUtil.java
luehe 2002/10/21 20:00:20 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java SmapUtil.java Log: Added support for prelude and coda to JSP documents Revision ChangesPath 1.20 +79 -31 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- JspDocumentParser.java17 Oct 2002 20:43:06 - 1.19 +++ JspDocumentParser.java22 Oct 2002 03:00:20 - 1.20 -61,7 +61,7 package org.apache.jasper.compiler; import java.io.*; -import java.util.Hashtable; +import java.util.*; import javax.servlet.jsp.tagext.*; import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.ParserConfigurationException; -92,19 +92,26 private ParserController parserController; private JspCompilationContext ctxt; +private PageInfo pageInfo; + // XML document source private InputSource inputSource; + private String path; + // Node representing the XML element currently being parsed private Node current; + // Document locator private Locator locator; + private Hashtable taglibs; + // Flag indicating whether we are inside DTD declarations private boolean inDTD; + private ErrorDispatcher err; private boolean isTagFile; -private boolean rootSeen; /* * Constructor -115,7 +122,8 boolean isTagFile) { this.parserController = pc; this.ctxt = pc.getJspCompilationContext(); - this.taglibs = pc.getCompiler().getPageInfo().getTagLibraries(); + this.pageInfo = pc.getCompiler().getPageInfo(); + this.taglibs = this.pageInfo.getTagLibraries(); this.err = pc.getCompiler().getErrorDispatcher(); this.path = path; this.inputSource = new InputSource(reader); -125,19 +133,32 /* * Parses a JSP document by responding to SAX events. * - * throws JasperException XXX + * throws JasperException */ public static Node.Nodes parse(ParserController pc, String path, InputStreamReader reader, Node parent, boolean isTagFile) throws JasperException { + JspDocumentParser handler = new JspDocumentParser(pc, path, reader, isTagFile); - handler.current = parent; Node.Nodes pageNodes = null; + Node.JspRoot jspRoot = null; try { + if (parent == null) { + // create dummy jsp:root element + AttributesImpl rootAttrs = new AttributesImpl(); + rootAttrs.addAttribute(, , version, CDATA, 2.0); + jspRoot = new Node.JspRoot(rootAttrs, null, null); + handler.current = jspRoot; + handler.addInclude(jspRoot, +handler.pageInfo.getIncludePrelude()); + } else { + handler.current = parent; + } + // Use the default (non-validating) parser SAXParserFactory factory = SAXParserFactory.newInstance(); -151,8 +172,9 saxParser.parse(handler.inputSource, handler); if (parent == null) { - // Add the jsp:root element to the parse result - pageNodes = new Node.Nodes((Node.JspRoot) handler.current); + handler.addInclude(jspRoot, handler.pageInfo.getIncludeCoda()); + // Create Node.Nodes from dummy (top-level) jsp:root + pageNodes = new Node.Nodes(jspRoot); } else { pageNodes = parent.getBody(); } -179,15 +201,6 Node node = null; - if (!qName.equals(JSP_ROOT) !rootSeen) { - // create dummy jsp:root element - AttributesImpl rootAttrs = new AttributesImpl(); - rootAttrs.addAttribute(, , version, CDATA, 2.0); - node = new Node.JspRoot(rootAttrs, null, current, true); - current = node; -rootSeen = true; - } - // XXX - As of JSP 2.0, xmlns: can appear in any node (not just // jsp:root). The spec still needs clarification here. // What we implement is that it can appear in any node and -205,8 +218,7 // give the jsp:root element the original attributes set // (attrs) instead of the copy without the xmlns: elements
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Parser.java TagLibraryInfoImpl.java
luehe 2002/07/25 12:02:16 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Parser.java TagLibraryInfoImpl.java Log: Integrated TagFileProcessor into TagLibraryInfo constructor Revision ChangesPath 1.9 +5 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- JspDocumentParser.java24 Jul 2002 19:58:57 - 1.8 +++ JspDocumentParser.java25 Jul 2002 19:02:16 - 1.9 @@ -483,8 +483,8 @@ // get the location String[] location = ctxt.getTldLocation(uri); -tl = new TagLibraryInfoImpl(ctxt, prefix, uri, location, - err); +tl = new TagLibraryInfoImpl(ctxt, parserController, prefix, + uri, location, err); } taglibs.put(prefix, tl); } 1.12 +6 -5 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Parser.java 22 Jul 2002 20:35:27 - 1.11 +++ Parser.java 25 Jul 2002 19:02:16 - 1.12 @@ -371,8 +371,9 @@ if (uri != null prefix != null) { // Errors to be checked in Validator String[] location = ctxt.getTldLocation(uri); - TagLibraryInfo tl = new TagLibraryInfoImpl(ctxt, prefix, uri, -location, err); + TagLibraryInfo tl = new TagLibraryInfoImpl(ctxt, parserController, +prefix, uri, location, +err); taglibs.put(prefix, tl); } 1.5 +51 -13 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java Index: TagLibraryInfoImpl.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TagLibraryInfoImpl.java 22 Jul 2002 23:02:55 - 1.4 +++ TagLibraryInfoImpl.java 25 Jul 2002 19:02:16 - 1.5 @@ -81,13 +81,14 @@ * @author Kin-man Chung */ public class TagLibraryInfoImpl extends TagLibraryInfo { -static private final String TAGLIB_TLD = META-INF/taglib.tld; -static private final String WEB_XML = /WEB-INF/web.xml; -Hashtable jarEntries; +private static final String TAGLIB_TLD = META-INF/taglib.tld; +private static final String WEB_XML = /WEB-INF/web.xml; -JspCompilationContext ctxt; -ErrorDispatcher err; +private Hashtable jarEntries; +private JspCompilationContext ctxt; +private ErrorDispatcher err; +private ParserController parserController; private final void print(String name, String value, PrintWriter w) { if (value != null) { @@ -141,14 +142,19 @@ } -public TagLibraryInfoImpl(JspCompilationContext ctxt, String prefix, - String uriIn, String[] location, - ErrorDispatcher err) -throws JasperException { - +/** + * Constructor. + */ +public TagLibraryInfoImpl(JspCompilationContext ctxt, + ParserController pc, + String prefix, + String uriIn, + String[] location, + ErrorDispatcher err) throws JasperException { super(prefix, uriIn); this.ctxt = ctxt; + this.parserController = pc; this.err = err; ZipInputStream zin; InputStream in = null; @@ -275,6 +281,8 @@ this.tagLibraryValidator = createValidator(element); else if (tag.equals(tname)) tagVector.addElement(createTagInfo(element)); +else if (tag-file.equals(tname)) +tagVector.addElement(createTagInfoFromTagFile(element)); else if (function.equals(tname))
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ErrorDispatcher.java DefaultErrorHandler.java
luehe 2002/07/24 12:58:57 Modified:jasper2/src/share/org/apache/jasper/resources messages.properties jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java ErrorDispatcher.java DefaultErrorHandler.java Log: added error message for jsp.error.parse.xml.scripting.invalid.body error code + fixed NPE in ErrorDispatcher Revision ChangesPath 1.13 +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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- messages.properties 22 Jul 2002 20:35:27 - 1.12 +++ messages.properties 24 Jul 2002 19:58:57 - 1.13 @@ -231,6 +231,7 @@ jsp.error.no.more.content=End of content reached while more parsing required: tag nesting error? jsp.error.parse.xml=XML parsing error on file {0}: {1} jsp.error.parse.xml.line=XML parsing error on file {0}: (line {1}, col {2}): {3} +jsp.error.parse.xml.scripting.invalid.body=Body of {0} element must not contain any XML elements jsp.error.internal.tldinit=Exception initializing TldLocationsCache: {0} jsp.error.internal.filenotfound=Internal Error: File {0} not found jsp.error.internal.evaluator_not_found=Internal error: unable to load expression evaluator 1.8 +15 -7 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- JspDocumentParser.java22 Jul 2002 23:02:55 - 1.7 +++ JspDocumentParser.java24 Jul 2002 19:58:57 - 1.8 @@ -314,7 +314,7 @@ } if (current instanceof Node.ScriptingElement) { - checkScriptingBody(current.getBody()); + checkScriptingBody((Node.ScriptingElement) current); } if (current.getParent() != null) { @@ -495,18 +495,26 @@ * Ensures that the given body only contains nodes that are instances of * TemplateText. * - * This check is performed only for the body of a scripting (that is, a + * This check is performed only for the body of a scripting (that is: * declaration, scriptlet, or expression) element, after the end tag of a * scripting element has been reached. */ -private void checkScriptingBody(Node.Nodes body) throws SAXException { +private void checkScriptingBody(Node.ScriptingElement scriptingElem) + throws SAXException { + Node.Nodes body = scriptingElem.getBody(); if (body != null) { int size = body.size(); for (int i=0; isize; i++) { Node n = body.getNode(i); if (!(n instanceof Node.TemplateText)) { + String elemType = TagConstants.JSP_SCRIPTLET; + if (scriptingElem instanceof Node.Declaration) + elemType = TagConstants.JSP_DECLARATION; + if (scriptingElem instanceof Node.Expression) + elemType = TagConstants.JSP_EXPRESSION; String msg = err.getString( -jsp.error.parse.xml.scripting.invalid.body); +jsp.error.parse.xml.scripting.invalid.body, + elemType); throw new SAXException(msg); } } 1.3 +10 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ErrorDispatcher.java Index: ErrorDispatcher.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ErrorDispatcher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ErrorDispatcher.java 15 May 2002 20:42:03 - 1.2 +++ ErrorDispatcher.java 24 Jul 2002 19:58:57 - 1.3 @@ -391,11 +391,15 @@ private void dispatch(Mark where, String errCode, Object[] args, Exception e) throws JasperException { String file = null; + String errMsg = null; int line = -1; int column = -1; // Localize - String errMsg = getString(errCode, args); + + if (errCode != null) { + errMsg = getString(errCode, args); + } // Get error location if (where !=
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java JspUtil.java PageDataImpl.java TagConstants.java TagLibraryInfoImpl.java
luehe 2002/07/22 16:02:55 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java JspUtil.java PageDataImpl.java TagConstants.java TagLibraryInfoImpl.java Log: Added support for Tag File directives in Tag File Documents Revision ChangesPath 1.7 +34 -25 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JspDocumentParser.java17 Jul 2002 20:06:58 - 1.6 +++ JspDocumentParser.java22 Jul 2002 23:02:55 - 1.7 @@ -183,21 +183,21 @@ Attributes attrsCopy = new AttributesImpl(attrs); Node node = null; - if (qName.equals(JSP_ROOT_TAG)) { + if (qName.equals(JSP_ROOT)) { node = new Node.JspRoot(attrsCopy, start, current); try { addCustomTagLibraries(attrsCopy); } catch (JasperException je) { throw new SAXException(je); } - } else if (qName.equals(JSP_PAGE_DIRECTIVE_TAG)) { + } else if (qName.equals(JSP_PAGE_DIRECTIVE)) { node = new Node.PageDirective(attrsCopy, start, current); String imports = attrs.getValue(import); // There can only be one 'import' attribute per page directive if (imports != null) { ((Node.PageDirective) node).addImport(imports); } - } else if (qName.equals(JSP_INCLUDE_DIRECTIVE_TAG)) { + } else if (qName.equals(JSP_INCLUDE_DIRECTIVE)) { node = new Node.IncludeDirective(attrsCopy, start, current); String file = attrsCopy.getValue(file); try { @@ -209,34 +209,42 @@ } catch (Exception e) { throw new SAXException(e); } - } else if (qName.equals(JSP_DECLARATION_TAG)) { + } else if (qName.equals(JSP_DECLARATION)) { node = new Node.Declaration(start, current); - } else if (qName.equals(JSP_SCRIPTLET_TAG)) { + } else if (qName.equals(JSP_SCRIPTLET)) { node = new Node.Scriptlet(start, current); - } else if (qName.equals(JSP_EXPRESSION_TAG)) { + } else if (qName.equals(JSP_EXPRESSION)) { node = new Node.Expression(start, current); - } else if (qName.equals(JSP_USE_BEAN_TAG)) { + } else if (qName.equals(JSP_USE_BEAN)) { node = new Node.UseBean(attrsCopy, start, current); - } else if (qName.equals(JSP_SET_PROPERTY_TAG)) { + } else if (qName.equals(JSP_SET_PROPERTY)) { node = new Node.SetProperty(attrsCopy, start, current); - } else if (qName.equals(JSP_GET_PROPERTY_TAG)) { + } else if (qName.equals(JSP_GET_PROPERTY)) { node = new Node.GetProperty(attrsCopy, start, current); - } else if (qName.equals(JSP_INCLUDE_TAG)) { + } else if (qName.equals(JSP_INCLUDE)) { node = new Node.IncludeAction(attrsCopy, start, current); - } else if (qName.equals(JSP_FORWARD_TAG)) { + } else if (qName.equals(JSP_FORWARD)) { node = new Node.ForwardAction(attrsCopy, start, current); - } else if (qName.equals(JSP_PARAM_TAG)) { + } else if (qName.equals(JSP_PARAM)) { node = new Node.ParamAction(attrsCopy, start, current); - } else if (qName.equals(JSP_PARAMS_TAG)) { + } else if (qName.equals(JSP_PARAMS)) { node = new Node.ParamsAction(start, current); - } else if (qName.equals(JSP_PLUGIN_TAG)) { + } else if (qName.equals(JSP_PLUGIN)) { node = new Node.PlugIn(attrsCopy, start, current); - } else if (qName.equals(JSP_TEXT_TAG)) { + } else if (qName.equals(JSP_TEXT)) { node = new Node.JspText(start, current); - } else if (qName.equals(JSP_BODY_TAG)) { + } else if (qName.equals(JSP_BODY)) { node = new Node.JspBody(attrsCopy, start, current); - } else if (qName.equals(JSP_ATTRIBUTE_TAG)) { + } else if (qName.equals(JSP_ATTRIBUTE)) { node = new Node.NamedAttribute(attrsCopy, start, current); + } else if (qName.equals(JSP_TAG_DIRECTIVE)) { + node = new Node.TagDirective(attrsCopy, start, current); + } else if (qName.equals(JSP_ATTRIBUTE_DIRECTIVE)) { + node = new Node.AttributeDirective(attrsCopy, start, current); + } else if (qName.equals(JSP_VARIABLE_DIRECTIVE)) { + node = new Node.VariableDirective(attrsCopy, start, current); + } else if (qName.equals(JSP_FRAGMENT_INPUT_DIRECTIVE)) { + node = new Node.FragmentInputDirective(attrsCopy, start, current); }
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java
costin 2002/06/20 16:02:16 Modified:jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Log: Use the cached TLDLibraryInfo. This is not perfect - we may look at the file timestamp and re-read it if modified. If you have problems with cached TLDLibInfo - you can comment this part out. ( I can add a flag to turn on caching ) Revision ChangesPath 1.3 +12 -8 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JspDocumentParser.java13 Jun 2002 18:56:18 - 1.2 +++ JspDocumentParser.java20 Jun 2002 23:02:16 - 1.3 @@ -439,11 +439,15 @@ uri = uri.substring(URN_JSPTLD.length()); } - // get the location - String[] location = ctxt.getTldLocation(uri); - - TagLibraryInfo tl = new TagLibraryInfoImpl(ctxt, prefix, uri, -location, err); +TldLocationsCache cache=ctxt.getOptions().getTldLocationsCache(); +TagLibraryInfo tl=cache.getTagLibraryInfo( uri ); +if( tl==null ) { +// get the location +String[] location = ctxt.getTldLocation(uri); + +tl = new TagLibraryInfoImpl(ctxt, prefix, uri, +location, err); +} taglibs.put(prefix, tl); } } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]