You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2009/12/30 17:04:23 UTC
svn commit: r894659 - in /tomcat/trunk/java/org/apache/jasper:
compiler/TldLocationsCache.java xmlparser/ParserUtils.java
Author: markt
Date: Wed Dec 30 16:04:23 2009
New Revision: 894659
URL: http://svn.apache.org/viewvc?rev=894659&view=rev
Log:
Get Jasper to use same web.xml (including merging if appropriate) as Catalina by default. If no merged web.xml is found, fall back to previous behaviour.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java
tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
Modified: tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java?rev=894659&r1=894658&r2=894659&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/TldLocationsCache.java Wed Dec 30 16:04:23 2009
@@ -17,6 +17,7 @@
package org.apache.jasper.compiler;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -237,50 +238,67 @@
* This is not kept in sync with o.a.c.startup.TldConfig as the Jasper only
* needs the URI to TLD mappings from scan web.xml whereas TldConfig needs
* to scan the actual TLD files.
+ *
+ * Search order is:
+ * - web.xml scanned by Tomcat and placed in context attribute
+ * - location specified by ALT_DD_ATTR
+ * - /WEB-INF/web.xml
*/
private void tldScanWebXml() throws Exception {
InputStream is = null;
+ String systemId = null;
try {
- // Acquire input stream to web application deployment descriptor
- String altDDName = (String)ctxt.getAttribute(
- Constants.ALT_DD_ATTR);
- URL uri = null;
- if (altDDName != null) {
- try {
- uri = new URL(FILE_PROTOCOL+altDDName.replace('\\', '/'));
- } catch (MalformedURLException e) {
- if (log.isWarnEnabled()) {
+ // Is a web.xml provided as context attribute?
+ String webXml = (String) ctxt.getAttribute(
+ org.apache.tomcat.util.scan.Constants.MERGED_WEB_XML);
+ if (webXml != null) {
+ is = new ByteArrayInputStream(webXml.getBytes());
+ systemId = org.apache.tomcat.util.scan.Constants.MERGED_WEB_XML;
+ }
+
+ // If not available as context attribute, look for an alternative
+ // location
+ if (is == null) {
+ // Acquire input stream to web application deployment descriptor
+ String altDDName = (String)ctxt.getAttribute(
+ Constants.ALT_DD_ATTR);
+ if (altDDName != null) {
+ try {
+ URL uri =
+ new URL(FILE_PROTOCOL+altDDName.replace('\\', '/'));
+ is = uri.openStream();
+ systemId = uri.toExternalForm();
+ } catch (MalformedURLException e) {
log.warn(Localizer.getMessage(
- "jsp.error.internal.filenotfound",
- altDDName));
+ "jsp.error.internal.filenotfound",
+ altDDName));
}
}
- } else {
- uri = ctxt.getResource(WEB_XML);
- if (uri == null && log.isWarnEnabled()) {
+ }
+
+ // Finally, try the default /WEB-INF/web.xml
+ if (is == null) {
+ URL uri = ctxt.getResource(WEB_XML);
+ if (uri == null) {
log.warn(Localizer.getMessage(
- "jsp.error.internal.filenotfound",
- WEB_XML));
+ "jsp.error.internal.filenotfound", WEB_XML));
+ } else {
+ is = uri.openStream();
+ systemId = uri.toExternalForm();
}
}
- if (uri == null) {
+ if (is == null) {
return;
}
- is = uri.openStream();
InputSource ip = new InputSource(is);
- ip.setSystemId(uri.toExternalForm());
+ ip.setSystemId(systemId);
// Parse the web application deployment descriptor
TreeNode webtld = null;
- // altDDName is the absolute path of the DD
- if (altDDName != null) {
- webtld = new ParserUtils().parseXMLDocument(altDDName, ip);
- } else {
- webtld = new ParserUtils().parseXMLDocument(WEB_XML, ip);
- }
+ webtld = new ParserUtils().parseXMLDocument(systemId, ip);
// Allow taglib to be an element of the root or jsp-config (JSP2.0)
TreeNode jspConfig = webtld.findChild("jsp-config");
Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java?rev=894659&r1=894658&r2=894659&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java Wed Dec 30 16:04:23 2009
@@ -73,13 +73,13 @@
* Parse the specified XML document, and return a <code>TreeNode</code>
* that corresponds to the root node of the document tree.
*
- * @param uri URI of the XML document being parsed
+ * @param location Location (eg URI) of the XML document being parsed
* @param is Input source containing the deployment descriptor
*
* @exception JasperException if an input/output error occurs
* @exception JasperException if a parsing error occurs
*/
- public TreeNode parseXMLDocument(String uri, InputSource is)
+ public TreeNode parseXMLDocument(String location, InputSource is)
throws JasperException {
Document document = null;
@@ -96,20 +96,20 @@
document = builder.parse(is);
} catch (ParserConfigurationException ex) {
throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), ex);
+ (Localizer.getMessage("jsp.error.parse.xml", location), ex);
} catch (SAXParseException ex) {
throw new JasperException
(Localizer.getMessage("jsp.error.parse.xml.line",
- uri,
+ location,
Integer.toString(ex.getLineNumber()),
Integer.toString(ex.getColumnNumber())),
ex);
} catch (SAXException sx) {
throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), sx);
+ (Localizer.getMessage("jsp.error.parse.xml", location), sx);
} catch (IOException io) {
throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), io);
+ (Localizer.getMessage("jsp.error.parse.xml", location), io);
}
// Convert the resulting document to a graph of TreeNodes
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org