You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Kelly Chen <ke...@tumbleweed.com> on 2003/01/29 20:31:07 UTC

Error when compiling JSP page with taglib using JspC

I ran into an Error when compile JSP page with taglib using JspC. This 
happens with the Jasper in Tomcat 4.1.12. The root of the exception is 
thrown by ServletContext.getResource, the exception is 
MalformedURLException. After some digging, the following code (in 
TagLibraryInfoImpl.java) looks dubious, because it intentionally strips 
out the "/" at the beginning of the path, however the Serlvet spec 
requires the path to be start with "/". See

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getResource(java.lang.String)

                if(ctxt.getClassLoader() != null &&
                   
URLClassLoader.class.equals(ctxt.getClassLoader().getClass())
                       && path.startsWith("/"))
                   path = path.substring(1,path.length()) ;

So I suggest to change the above lines to the following to guarantee 
that path is started with "/":
                if(ctxt.getClassLoader() != null &&
                   
URLClassLoader.class.equals(ctxt.getClassLoader().getClass())
                       && !path.startsWith("/"))
                   path = "/" +path ;

One thing that I haven't spent much time on is that why JSP pages with 
Taglib compiled OK in Tomcat, I just assume that it might be executing 
the different code path. If a regular Jasper developer could examine if 
the above change makes sense, I would like submit the change to the code 
base. Since I am not a regular developer, I am just posting to the list 
for now.


-- 
Kelly Chen                       Tumbleweed Communication Corp.
T:650-216-2043                   700 Saginaw Drive
F:650-216-2565                   Redwood City, CA 94063





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