tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pier...@locus.apache.org
Subject cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet JspServlet.java
Date Tue, 31 Oct 2000 22:54:17 GMT
pierred     00/10/31 14:54:16

  Modified:    catalina/src/conf web.xml
               jasper/src/share/org/apache/jasper CommandLineContext.java
                        JspCompilationContext.java JspEngineContext.java
               jasper/src/share/org/apache/jasper/compiler
                        JspParseEventListener.java TagLibraryInfoImpl.java
               jasper/src/share/org/apache/jasper/resources
                        messages.properties
               jasper/src/share/org/apache/jasper/servlet JspServlet.java
  Log:
  
  
  Revision  Changes    Path
  1.10      +0 -2      jakarta-tomcat-4.0/catalina/src/conf/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/conf/web.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- web.xml	2000/10/12 23:34:10	1.9
  +++ web.xml	2000/10/31 22:54:07	1.10
  @@ -50,9 +50,7 @@
         <param-name>logVerbosityLevel</param-name>
         <param-value>WARNING</param-value>
       </init-param>
  -<!--
       <load-on-startup>4</load-on-startup>
  --->
     </servlet>
   
   
  
  
  
  1.3       +11 -3     jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/CommandLineContext.java
  
  Index: CommandLineContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/CommandLineContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CommandLineContext.java	2000/08/31 15:49:39	1.2
  +++ CommandLineContext.java	2000/10/31 22:54:09	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/CommandLineContext.java,v
1.2 2000/08/31 15:49:39 shemnon Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/08/31 15:49:39 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/CommandLineContext.java,v
1.3 2000/10/31 22:54:09 pierred Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/10/31 22:54:09 $
    *
    * ====================================================================
    * 
  @@ -76,6 +76,8 @@
   //import org.apache.jasper.runtime.JspLoader;
   // Use the jasper loader - the only function used is to add a jar
   import org.apache.jasper.servlet.JasperLoader;
  +import java.net.URL;
  +import java.net.MalformedURLException;
   
   /**
    * Holds data used on a per-page compilation context that would otherwise spill
  @@ -369,6 +371,12 @@
           return in;
       }
   
  +    public java.net.URL getResource(String res) 
  +	throws MalformedURLException
  +    {
  +	// FIXME @@@
  +	return null;
  +    }
   
       /** 
        * Gets the actual path of a URI relative to the context of
  
  
  
  1.2       +7 -3      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspCompilationContext.java
  
  Index: JspCompilationContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspCompilationContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JspCompilationContext.java	2000/08/12 00:52:05	1.1
  +++ JspCompilationContext.java	2000/10/31 22:54:09	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspCompilationContext.java,v
1.1 2000/08/12 00:52:05 pierred Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/08/12 00:52:05 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspCompilationContext.java,v
1.2 2000/10/31 22:54:09 pierred Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/10/31 22:54:09 $
    *
    * ====================================================================
    * 
  @@ -70,6 +70,8 @@
   //import org.apache.jasper.runtime.JspLoader;
   import org.apache.jasper.compiler.TagLibraries;
   import java.io.IOException;
  +import java.net.URL;
  +import java.net.MalformedURLException;
   import org.apache.jasper.compiler.Compiler;
   
   /**
  @@ -202,6 +204,8 @@
        *         as an InputStream.
        */
       public java.io.InputStream getResourceAsStream(String res);
  +
  +    public java.net.URL getResource(String res) throws MalformedURLException;
   
       /** 
        * Gets the actual path of a URI relative to the context of
  
  
  
  1.2       +11 -3     jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspEngineContext.java
  
  Index: JspEngineContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspEngineContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JspEngineContext.java	2000/08/12 00:52:05	1.1
  +++ JspEngineContext.java	2000/10/31 22:54:10	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspEngineContext.java,v
1.1 2000/08/12 00:52:05 pierred Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/08/12 00:52:05 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspEngineContext.java,v
1.2 2000/10/31 22:54:10 pierred Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/10/31 22:54:10 $
    *
    * ====================================================================
    * 
  @@ -65,6 +65,8 @@
   
   package org.apache.jasper;
   
  +import java.net.URL;
  +import java.net.MalformedURLException;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  @@ -346,6 +348,12 @@
       public java.io.InputStream getResourceAsStream(String res)
       {
           return context.getResourceAsStream(res);
  +    }
  +
  +    public java.net.URL getResource(String res)
  +	throws MalformedURLException
  +    {
  +        return context.getResource(res);
       }
   
       /** 
  
  
  
  1.10      +12 -5     jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java
  
  Index: JspParseEventListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JspParseEventListener.java	2000/10/28 03:20:19	1.9
  +++ JspParseEventListener.java	2000/10/31 22:54:11	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
1.9 2000/10/28 03:20:19 pierred Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/10/28 03:20:19 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
1.10 2000/10/31 22:54:11 pierred Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/10/31 22:54:11 $
    *
    * ====================================================================
    *
  @@ -735,8 +735,15 @@
   	if (directive.equals("taglib")) {
               String uri = attrs.getValue("uri");
               String prefix = attrs.getValue("prefix");
  -	    TagLibraryInfo tl = 
  -		new TagLibraryInfoImpl(ctxt, prefix, uri);
  +	    TagLibraryInfo tl = null;
  +
  +	    String[] location = 
  +		TagLibrariesGlobal.getLocation(uri);
  +	    if (location == null) {
  +		tl = new TagLibraryInfoImpl(ctxt, prefix, uri);
  +	    } else {
  +		tl = new TagLibraryInfoImpl(ctxt, prefix, uri, location);
  +	    }
   	    libraries.addTagLibrary(prefix, tl);
   	}
   
  
  
  
  1.9       +81 -169   jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java
  
  Index: TagLibraryInfoImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TagLibraryInfoImpl.java	2000/10/29 06:10:08	1.8
  +++ TagLibraryInfoImpl.java	2000/10/31 22:54:12	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
1.8 2000/10/29 06:10:08 pierred Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/10/29 06:10:08 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
1.9 2000/10/31 22:54:12 pierred Exp $
  + * $Revision: 1.9 $
  + * $Date: 2000/10/31 22:54:12 $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -60,8 +60,12 @@
   package org.apache.jasper.compiler;
   
   import java.net.URL;
  +import java.net.MalformedURLException;
  +import java.net.JarURLConnection;
   import java.util.zip.ZipInputStream;
   import java.util.zip.ZipEntry;
  +import java.util.jar.*;
  +import java.util.Enumeration;
   import java.io.ByteArrayOutputStream;
   import java.io.ByteArrayInputStream;
   import java.io.FileInputStream;
  @@ -157,9 +161,17 @@
           }
       }
   
  -    public TagLibraryInfoImpl(JspCompilationContext ctxt, String prefix, String uriIn)

  +    public TagLibraryInfoImpl(JspCompilationContext ctxt, String prefix, 
  +			      String uriIn) 
           throws JasperException
       {
  +	this(ctxt, prefix, uriIn, null);
  +    }
  +
  +    public TagLibraryInfoImpl(JspCompilationContext ctxt, String prefix, 
  +			      String uriIn, String[] location) 
  +        throws JasperException
  +    {
           super(prefix, uriIn);
   
   	this.ctxt = ctxt;
  @@ -167,181 +179,77 @@
           InputStream in = null;
           URL url = null;
           boolean relativeURL = false;
  -	this.uri = uriIn;
   
  -        // Parse web.xml.
  -	InputStream is;
  -	try {
  -	    is = getResourceAsStream(WEB_XML);
  -	} catch (FileNotFoundException ex) {
  -	    throw new JasperException(
  -		Constants.getString("jsp.error.internal.file.not.found", 
  -				    new Object[]{WEB_XML}));
  +	if (location == null) {
  +	    // The URI points to the TLD itself or to a jar
  +	    // file where the TLD is located
  +	    int uriType = TagLibrariesGlobal.uriType(uri);
  +	    if (uriType == TagLibrariesGlobal.ABS_URI) {
  +		throw new JasperException(
  +                    Constants.getString("jsp.error.absUriCannotBeResolved",
  +					new Object[] {uri}));
  +	    } else if (uriType == 
  +		       TagLibrariesGlobal.NOROOT_REL_URI) {
  +		uri = ctxt.resolveRelativeUri(uri);
  +	    }
  +	    location = new String[2];
  +	    location[0] = uri;
  +	    if (uri.endsWith("jar")) {
  +		location[1] = "META-INF/taglib.tld";
  +	    }
   	}
  -        if (is != null) {
  -            Document webtld =
  -                JspUtil.parseXMLDoc(WEB_XML, is);
  -            NodeList nList =  webtld.getElementsByTagName("taglib");
  -
  -            if (nList.getLength() != 0) {
  -                for(int i = 0; i < nList.getLength(); i++) {
  -                    String tagLoc = null;
  -                    boolean match = false;
  -                    Element e =  (Element) nList.item(i);
  -
  -                    // Assume only one entry for location and uri.
  -                    NodeList uriList = e.getElementsByTagName("taglib-uri");
  -                    Element uriElem = (Element) uriList.item(0);
  -                    Text t = (Text) uriElem.getFirstChild();
  -
  -                    if (t != null) {
  -                        String tmpUri = t.getData();
  -                        if (tmpUri != null) {
  -                            tmpUri = tmpUri.trim();
  -                            if (tmpUri.equals(uriIn)) {
  -                                match = true;
  -                                NodeList locList = e.getElementsByTagName
  -                                    ("taglib-location");
  -                                Element locElem = (Element) locList.item(0);
  -                                Text tl = (Text) locElem.getFirstChild();
  -                                if (tl != null) {
  -                                    tagLoc = tl.getData();
  -                                    if (tagLoc != null)
  -                                        tagLoc = tagLoc.trim();
  -                                }
  -                            }
  -                        }
  -                    }
  -                    if (match == true && tagLoc != null) {
  -                        this.uri = tagLoc;
  -
  -                        // If this is a relative path, then it has to be
  -                        // relative to where web.xml is.
  -
  -                        // I'm taking the simple way out. Since web.xml 
  -                        // has to be directly under WEB-INF, I'm making 
  -                        // an absolute URI out of it by prepending WEB-INF
  -
  -                        if (!uri.startsWith("/") && isRelativeURI(uri))
  -                            uri = "/WEB-INF/"+uri;
  -                    }
  -                }
  -            }
  -        }
  -
  -        // Try to resolve URI relative to the current JSP page
  -        if (!uri.startsWith("/") && isRelativeURI(uri))
  -            uri = ctxt.resolveRelativeUri(uri);
  -
   
  -        if (!uri.endsWith("jar")) {
  +        if (!location[0].endsWith("jar")) {
  +	    // Location points to TLD file
   	    try {
  -		in = getResourceAsStream(uri);
  -		if (in == null) throw new FileNotFoundException(uri);
  +		in = getResourceAsStream(location[0]);
  +		if (in == null) throw new FileNotFoundException(location[0]);
   	    } catch (FileNotFoundException ex) {
   		throw new JasperException(
                       Constants.getString("jsp.error.file.not.found",
  -					new Object[] {uri}));
  +					new Object[] {location[0]}));
   	    }
   	    // Now parse the tld.
  -	    parseTLD(uri, in);
  -	}
  -	    
  -	// FIXME Take this stuff out when taglib changes are thoroughly tested.
  -	/* @@@ taking it out... hopefully the sky won't fall -pierred
  -	if (uri.endsWith("jar")) {
  -	    
  -	    if (!isRelativeURI(uri)) {
  -		url = new URL(uri);
  -		in = url.openStream();
  -	    } else {
  -		relativeURL = true;
  -		in = getResourceAsStream(uri);
  -	    }
  -	    
  -	    zin = new ZipInputStream(in);
  -	    this.jarEntries = new Hashtable();
  -	    this.ctxt = ctxt;
  -	    
  -	    // First copy this file into our work directory! 
  -	    {
  -		File jspFile = new File(ctxt.getJspFile());
  -                String parent = jspFile.getParent();
  -                String jarFileName = ctxt.getOutputDir();
  -                if (parent != null) {
  -                   jarFileName = jarFileName + File.separatorChar +
  -                       parent;
  -                }
  -                File jspDir = new File(jarFileName);
  -		jspDir.mkdirs();
  -	    
  -		if (relativeURL)
  -		    jarFileName = jarFileName+File.separatorChar+new File(uri).getName();
  -		else                    
  -		    jarFileName = jarFileName+File.separatorChar+
  -			new File(url.getFile()).getName();
  -	    
  -		Constants.message("jsp.message.copyinguri", 
  -	                          new Object[] { uri, jarFileName },
  -				  Logger.DEBUG);
  -	    
  -		if (relativeURL)
  -		    copy(getResourceAsStream(uri),
  -			 jarFileName);
  -		else
  -		    copy(url.openStream(), jarFileName);
  -	    
  -	        ctxt.addJar(jarFileName);
  -	    }
  -	    
  -	    
  -	    boolean tldFound = false;
  -	    ZipEntry entry;
  -	    while ((entry = zin.getNextEntry()) != null) {
  -		if (entry.getName().equals(TAGLIB_TLD)) {
  -		    // This hack is necessary because XML reads until the end 
  -		    // of an inputstream -- does not use available()
  -		    // -- and closes the inputstream when it can't
  -		    // read no more.
  -		    
  -		    // BEGIN HACK
  -		    ByteArrayOutputStream baos = new ByteArrayOutputStream();
  -		    int b;
  -		    while (zin.available() != 0) {
  -			b = zin.read();
  -			if (b == -1)
  -			    break;
  -			baos.write(b);
  -		    }
  -
  -		    baos.close();
  -		    ByteArrayInputStream bais 
  -			= new ByteArrayInputStream(baos.toByteArray());
  -		    // END HACK
  -		    tldFound = true;
  -		    parseTLD(TAGLIB_TLD, bais);
  -		} else {
  -		    ByteArrayOutputStream baos = new ByteArrayOutputStream();
  -		    int b;
  -		    while (zin.available() != 0) {
  -			b = zin.read();
  -			if (b == -1)
  -			    break;
  -			baos.write(b);
  -		    }
  -		    baos.close();
  -		    jarEntries.put(entry.getName(), baos.toByteArray());
  +	    parseTLD(location[0], in);
  +	} else {
  +	    // Location points to a jar file
  +	    p("JAR FILE: " + location[0]);
  +	    // tag library in jar file
  +	    JarFile jarFile = null;
  +	    ZipEntry jarEntry = null;
  +	    InputStream stream = null;
  +	    try {
  +		url = ctxt.getResource(location[0]);
  +		p("url = " + url);
  +		if (url == null) return;
  +		url = new URL("jar:" + url.toString() + "!/");
  +		JarURLConnection conn =
  +		    (JarURLConnection) url.openConnection();
  +		conn.connect(); //@@@ necessary???
  +		jarFile = conn.getJarFile();
  +		p("jarFile: " + jarFile);
  +		jarEntry = jarFile.getEntry(location[1]);
  +		p("jarEntry name: " + jarEntry.getName());
  +		stream = jarFile.getInputStream(jarEntry);
  +		parseTLD(location[0], stream);
  +		// FIXME @@@
  +		// -- it seems that the JarURLConnection class caches JarFile 
  +		// objects for particular URLs, and there is no way to get 
  +		// it to release the cached entry, so
  +		// there's no way to redeploy from the same JAR file.  Wierd.
  +	    } catch (Exception ex) {
  +		if (stream != null) {
  +		    try {
  +			stream.close();
  +		    } catch (Throwable t) {}
   		}
  -		zin.closeEntry();
  -	    }
  -	    
  -	    if (!tldFound) {
  -		throw new JasperException(
  -                    Constants.getString("jsp.error.tld_not_found",
  -		                        new Object[] {TAGLIB_TLD}));
  +		if (jarFile != null) {
  +		    try {
  +			jarFile.close();
  +		    } catch (Throwable t) {}
  +		}
   	    }
  -	} // Take this out (END of if(endsWith("jar")))
  -        */
  +	}
       }
       
       /** Returns true if the given URI is relative in this web application, false if it
is an internet URI.
  @@ -647,7 +555,7 @@
                   Class tlvClass = 
   		    ctxt.getClassLoader().loadClass(validatorClass);
                   tlv = (TagLibraryValidator)tlvClass.newInstance();
  -                //@@@ removed in 1.2PFD tlv.setTagLibraryInfo(this);
  +		//p("got validator class: " + tlv);
               } catch (Exception ex) {
                   Constants.message("jsp.warning.tlvclass.is.null",
   				  new Object[] {
  @@ -729,4 +637,8 @@
       }
   
       protected TagLibraryValidator tagLibraryValidator; 
  +
  +    private void p(String s) {
  +	System.out.println("[TagLibraryInfoImpl] " + s);
  +    }
   }
  
  
  
  1.8       +3 -1      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages.properties,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- messages.properties	2000/10/29 03:23:51	1.7
  +++ messages.properties	2000/10/31 22:54:13	1.8
  @@ -1,4 +1,4 @@
  -# $Id: messages.properties,v 1.7 2000/10/29 03:23:51 pierred Exp $
  +# $Id: messages.properties,v 1.8 2000/10/31 22:54:13 pierred Exp $
   #
   # Default localized string information
   # Localized this the Default Locale as is en_US
  @@ -228,3 +228,5 @@
   jsp.error.unsupported.encoding=Unsupported encoding: {0}
   jsp.warning.unknown.element.in.variable=Warning: Unknown element {0} in variable
   tld.error.variableNotAllowed=It is an error for a tag that has one or more variable subelements
to have a TagExtraInfo class that returns a non-null object.
  +jsp.error.tldInWebDotXmlNotFound=Could not locate TLD {1} for URI {0} specified in web.xml
  +jsp.error.taglibDirective.absUriCannotBeResolved=This absolute uri ({0}) cannot be resolved
in either web.xml or the jar files deployed with this application
  
  
  
  1.6       +4 -0      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/JspServlet.java
  
  Index: JspServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/servlet/JspServlet.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JspServlet.java	2000/10/31 22:12:20	1.5
  +++ JspServlet.java	2000/10/31 22:54:16	1.6
  @@ -83,6 +83,7 @@
   import org.apache.jasper.runtime.*;
   
   import org.apache.jasper.compiler.Compiler;
  +import org.apache.jasper.compiler.TagLibrariesGlobal;
   
   import org.apache.jasper.logging.Logger;
   import org.apache.jasper.logging.JasperLogger;
  @@ -285,6 +286,9 @@
   	    Object pd=context.getAttribute("org.apache.tomcat.protection_domain");
   	    loader.setProtectionDomain( pd );
   	}
  +
  +	// Setup the Tag Libraries mappings
  +	TagLibrariesGlobal.init(context);
   
   	if (firstTime) {
   	    firstTime = false;
  
  
  

Mime
View raw message