tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: ServletContext.getResource() never null?
Date Mon, 13 Aug 2001 23:07:19 GMT


On Mon, 13 Aug 2001, chris monster wrote:

> in the api-docs for ServletContext.getResource( String path ), it is
> further specified that:
> 
> 
> "This method returns null if no resource is mapped to the pathname."
> 
> and
> 
> "The path must begin with a "/"..."
> 
> 
> are these stipulations in the servlet api-docs valid?
> 

Starting with Servlet 2.3, the API Javadocs are even included inside the
spec.  You can assume that they are authoritative.

> 
> in testing several containers including Tomcat 3.1.1, i was unable to
> get a null ( where a test for null would have been, um, desirable ), nor
> did it appear that the presence or absence of a leading "/" made any
> difference.
> 

Sounds like a bug in 3.1.1.  But it's unlikely anyone is going to bend
over backwards to fix it -- Tomcat 3.2 was released nine months ago
(current version is 3.2.3), and Tomcat 4.0 will be released as soon as the
servlet 2.3 and JSP 1.2 specs go final (real soon now).

By the way, at 3.2's initial release there were at least 150 bug fixes to
problems in 3.1, so this is not the only problem you will run into.

> 
> by way of contrast, consider the tantalizingly similar:
> 
> 
> java.lang.ClassLoader.getResource( String path )
> 
> which specifically does *not* expect a leading slash, and very
> definitely returns null when the resource does not exist.
>  

It also looks a totally different place -- inside /WEB-INF/classes or
inside JAR files under /WEB-INF/lib.

> 
> 
> reference:
> 
> http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletContext.html
> 
> http://java.sun.com/j2se/1.3/docs/api/java/lang/ClassLoader.html
> 

Craig McClanahan



Mime
View raw message