> From: Christopher Schultz [mailto:ch...@christopherschultz.net]
> Subject: Re: servlet access to static resources (pictures)
> 
> > We have defined some paths to static resources in the server.xml:
> Where did you define these <Context> elements?

Looks like the OP was pretty specific about where...

> > Is there a way to get the absolute paths of these folders in a
> > servlet?
> 
> Typically, one uses the request.getRealPath() method to find
> context-relative paths on a filesystem.

However, these are static-content only "webapps", there are no servlets in that 
context that can do a request.getRealPath(), which, as you noted, is a bad idea 
anyhow.

> Instead, try looking at the request.getResource family of methods:

Again, these are static-only "webapps", so there are no servlets or JSPs around 
to handle requests, other than Tomcat's DefaultServlet.

> If you just want to serve static resources, why not use the
> DefaultServlet, which already knows how to serve them?

Clearly, the OP is already doing that.  I suspect the actual problem is that 
there are other, real webapps that want to manipulate the static resources.  
Best I can think of is environment variables or Java system properties to allow 
specification of the locations on a JVM-wide basis.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.

Reply via email to