tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brett Bergquist" <>
Subject RE: getRealPath("/") and getRealPath("")
Date Tue, 02 Jan 2001 23:58:05 GMT
Craig, you mention that a container is not required to run your web
application out of filesystem, but could run it out of a JAR, etc. and
mention to use getResource and getResourceAsStream.  Now I do this for
anything that I need read-only support, but what if a web application needs
read-write support for things such as data files, etc.  I would prefer that
these files be part of the installed web application.  What would a
container do in these cases.

Thanks for your insight.

Brett M. Bergquist

-----Original Message-----
From: Craig R. McClanahan []
Sent: Tuesday, January 02, 2001 5:08 PM
Subject: Re: getRealPath("/") and getRealPath("")

chris monster wrote:

> apologies if i have missed a previous posting in my searches.
> in cross-testing our webapp between Tomcat 3.1 and another container
> (Resin 1.2.1) for compliance, i noticed that the behaviour of
> ServletContext.getRealPath() is different when applied to the
> application root.  ( actually, after checking the 2.2 spec, i suspect
> this may not be well defined. )
> for getRealPath("/") AND getRealPath("")
> Tomcat 3.1 returns:
> realpath/
> whereas the other container returns:
> realpath
> (without the trailing path-separator)
> i'm coding around this difference right now, but i'm curious who i
> should be bugging about this.  (get it, 'bugging'? ;)

Since this would be a spec interpretation issue, the best place to send
"bugging" messages would be to the spec feedback address printed on the
front of
the servlet spec:

Tomcat (and every other container) should implement what the spec says.  If
spec is silent on a particular issue, then the appropriate thing to do would
lobby for clarification in the next version -- which is timely now, because
Servlet 2.3 spec is currently in "proposed final draft" stage, not "final".

> chris monster

Craig McClanahan

PS:  As a side issue, I would encourage web app developers to start using
ServletContext.getResource() and ServletContext.getResourceAsStream(),
of ServletContext.getRealPath() followed by file I/O, to access internal
resources.  The reason for this is that a servlet container is *not*
required to
run your web app out of a filesystem (as Tomcat currently does) -- it may
them directly from a JAR file, or in an environment like Oracle's where the
app's resources are actually BLOB objects stored in a database, rather than
being accessible as files.

To unsubscribe, e-mail:
For additional commands, email:

View raw message