Author: remy.maucherat(a)jboss.com
Date: 2009-10-21 11:59:16 -0400 (Wed, 21 Oct 2009)
New Revision: 1214
Modified:
trunk/java/org/apache/jasper/JspCompilationContext.java
trunk/java/org/apache/jasper/compiler/Generator.java
trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
Log:
- Bring back the mysterious relative uri translation code, it is actually useful
sometimes.
Modified: trunk/java/org/apache/jasper/JspCompilationContext.java
===================================================================
--- trunk/java/org/apache/jasper/JspCompilationContext.java 2009-10-20 13:38:32 UTC (rev
1213)
+++ trunk/java/org/apache/jasper/JspCompilationContext.java 2009-10-21 15:59:16 UTC (rev
1214)
@@ -569,14 +569,6 @@
}
return location;
}
- /*
- System.out.print("Look for: " + uri + " TLDs list: ");
- Iterator<String> keys = jspTagLibraries.keySet().iterator();
- while (keys.hasNext()) {
- System.out.print(keys.next() + ", ");
- }
- System.out.println();
- */
}
/**
Modified: trunk/java/org/apache/jasper/compiler/Generator.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Generator.java 2009-10-20 13:38:32 UTC (rev
1213)
+++ trunk/java/org/apache/jasper/compiler/Generator.java 2009-10-21 15:59:16 UTC (rev
1214)
@@ -644,7 +644,7 @@
out.println(");");
if (ctxt.getOptions().isXpoweredBy()) {
- out.printil("response.addHeader(\"X-Powered-By\",
\"JSP/2.1\");");
+ out.printil("response.addHeader(\"X-Powered-By\",
\"JSP/2.2\");");
}
out
Modified: trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-10-20 13:38:32 UTC
(rev 1213)
+++ trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-10-21 15:59:16 UTC
(rev 1214)
@@ -145,6 +145,15 @@
this.pi = pi;
this.err = err;
+ if (location == null) {
+ // The URI points to the TLD itself or to a JAR file in which the
+ // TLD is stored
+ location = generateTLDLocation(uri, ctxt);
+ if (location != null) {
+ uri = location[0];
+ }
+ }
+
URL jarFileUrl = null;
if (location == null) {
err.jspError("jsp.error.file.not.found", uriIn);
@@ -159,7 +168,7 @@
org.apache.catalina.deploy.jsp.TagLibraryInfo tagLibraryInfo =
((HashMap<String, org.apache.catalina.deploy.jsp.TagLibraryInfo>)
-
ctxt.getServletContext().getAttribute(Globals.JSP_TAG_LIBRARIES)).get(uriIn);
+ ctxt.getServletContext().getAttribute(Globals.JSP_TAG_LIBRARIES)).get(uri);
ArrayList<TagInfo> tagInfos = new ArrayList<TagInfo>();
ArrayList<TagFileInfo> tagFileInfos = new ArrayList<TagFileInfo>();
@@ -207,6 +216,45 @@
this.functions = functionInfos.values().toArray(new FunctionInfo[0]);
}
+ /**
+ * @param uri The uri of the TLD @param ctxt The compilation context
+ *
+ * @return String array whose first element denotes the path to the TLD. If
+ * the path to the TLD points to a jar file, then the second element denotes
+ * the name of the TLD entry in the jar file, which is hardcoded to
+ * META-INF/taglib.tld.
+ */
+ private String[] generateTLDLocation(String uri, JspCompilationContext ctxt)
+ throws JasperException {
+
+ int uriType = uriType(uri);
+ if (uriType == ABS_URI) {
+ err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
+ uri);
+ } else if (uriType == NOROOT_REL_URI) {
+ uri = ctxt.resolveRelativeUri(uri);
+ }
+
+ String[] location = new String[2];
+ location[0] = uri;
+ if (location[0].endsWith("jar")) {
+ URL url = null;
+ try {
+ url = ctxt.getResource(location[0]);
+ } catch (Exception ex) {
+ err.jspError("jsp.error.tld.unable_to_get_jar", location[0],
ex
+ .toString());
+ }
+ if (url == null) {
+ err.jspError("jsp.error.tld.missing_jar", location[0]);
+ }
+ location[0] = url.toString();
+ location[1] = "META-INF/taglib.tld";
+ }
+
+ return location;
+ }
+
public TagLibraryInfo[] getTagLibraryInfos() {
Collection coll = pi.getTaglibs();
return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]);
Show replies by date