users@glassfish.java.net

Re: Read file from docroot

From: <glassfish_at_javadesktop.org>
Date: Tue, 06 Nov 2007 10:58:44 PST

Passing a path that starts with "../" as an argument to ServletContext.getResource() is invalid (and will cause an error) as per the javadocs of ServletContext.getResource(String path):

     * Returns a URL to the resource that is mapped to a specified
     * path. The path must begin with a "/" and is interpreted
     * as relative to the current context root.

This means that the use of this API will be portable across containers.

As for being able to update the returned resource, the javadocs also specifies this:

     * Some containers may allow writing to the URL returned by
     * this method using the methods of the URL class.


Jan
[Message sent by forum member 'jluehe' (jluehe)]

http://forums.java.net/jive/thread.jspa?messageID=244128