You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2003/04/15 21:55:51 UTC

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources messages.properties

luehe       2003/04/15 12:55:51

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        TagLibraryInfoImpl.java
               jasper2/src/share/org/apache/jasper/resources
                        messages.properties
  Log:
  Fixed Bugzilla 19032 ("MalformedURLException returned by Jasper when attempting to process a tag library packaged in JSP 1.1 fashion")
  
  Revision  Changes    Path
  1.39      +50 -25    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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- TagLibraryInfoImpl.java	12 Apr 2003 13:54:27 -0000	1.38
  +++ TagLibraryInfoImpl.java	15 Apr 2003 19:55:51 -0000	1.39
  @@ -163,29 +163,16 @@
   	this.err = err;
           ZipInputStream zin;
           InputStream in = null;
  -        URL url = null;
           boolean relativeURL = false;
           JarFile jarFile = null;
   
   	if (location == null) {
  -	    // The URI points to the TLD itself or to a jar file where the TLD
  -	    // is stored
  -	    int uriType = TldLocationsCache.uriType(uri);
  -	    if (uriType == TldLocationsCache.ABS_URI) {
  -		err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
  -			     uri);
  -	    } else if (uriType == TldLocationsCache.NOROOT_REL_URI) {
  -		uri = ctxt.resolveRelativeUri(uri);
  -	    }
  -	    location = new String[2];
  -	    location[0] = uri;
  -	    if (uri.endsWith("jar")) {
  -		location[1] = "META-INF/taglib.tld";
  -	    }
  +	    // The URI points to the TLD itself or to a JAR file in which the
  +	    // TLD is stored
  +	    location = generateTLDLocation(uri, ctxt);
   	}
   
           try {
  -
               if (!location[0].endsWith("jar")) {
                   // Location points to TLD file
                   try {
  @@ -196,9 +183,8 @@
                   } catch (FileNotFoundException ex) {
                       err.jspError("jsp.error.file.not.found", location[0]);
                   }
  -                // Now parse the tld.
                   parseTLD(ctxt, location[0], in, null);
  -                // Add the TLD to dependency list
  +                // Add TLD to dependency list
                   PageInfo pageInfo = ctxt.createCompiler().getPageInfo();
                   if (pageInfo != null) {
                       pageInfo.addDependant(location[0]);
  @@ -208,9 +194,8 @@
                   ZipEntry jarEntry = null;
                   JarURLConnection conn = null;
                   try {
  -                    url = new URL("jar:" + location[0] + "!/");
  -                    conn = (JarURLConnection)
  -                        url.openConnection();
  +                    URL url = new URL("jar:" + location[0] + "!/");
  +                    conn = (JarURLConnection) url.openConnection();
                       conn.connect(); //@@@ necessary???
                       jarFile = conn.getJarFile();
                       jarEntry = jarFile.getEntry(location[1]);
  @@ -226,7 +211,6 @@
                                    location[1], ex.toString());
                   }
               }
  -
           } finally {
               if (in != null) {
                   try {
  @@ -333,6 +317,47 @@
   	while (enum.hasMoreElements()) {
   	    this.functions[i++] = (FunctionInfo) enum.nextElement();
   	}
  +    }
  +    
  +    /*
  +     * @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 = TldLocationsCache.uriType(uri);
  +	if (uriType == TldLocationsCache.ABS_URI) {
  +	    err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
  +			 uri);
  +	} else if (uriType == TldLocationsCache.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;
       }
   
       private TagInfo createTagInfo(TreeNode elem) throws JasperException {
  
  
  
  1.114     +3 -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.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- messages.properties	11 Apr 2003 22:41:58 -0000	1.113
  +++ messages.properties	15 Apr 2003 19:55:51 -0000	1.114
  @@ -169,6 +169,8 @@
   jsp.error.missing_attribute=According to the TLD attribute {0} is mandatory for tag {1}
   jsp.error.bad_attribute=Attribute {0} invalid for tag {1} according to TLD
   jsp.error.tld.unable_to_read=Unable to read TLD \"{1}\" from JAR file \"{0}\": {2}
  +jsp.error.tld.unable_to_get_jar=Unable to get JAR resource \"{0}\" containing TLD: {1}
  +jsp.error.tld.missing_jar=Missing JAR resource \"{0}\" containing TLD
   jsp.error.webxml_not_found=Could not locate web.xml
   jsp.cmd_line.usage=Usage: jsptoservlet [-dd <path/to/outputDirectory>] [-keepgenerated] \
   <.jsp files>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org