On Sat, Sep 01, 2001 at 09:48:10PM -0700, Craig R. McClanahan wrote:
>
>
> On Mon, 27 Aug 2001, Rick Mann wrote:
>
> > Date: Mon, 27 Aug 2001 20:28:17 -0700
> > From: Rick Mann <[EMAIL PROTECTED]>
> > Reply-To: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> > Subject: Is there a way to get the "docBase" property from within a
> > servlet?
> >
> > Is there a Servlet spec-compliant way to get the webapp's directory's path
> > programmatically, from within a servlet?
>
> No.
getServletConfig().getServletContext().getRealPath("/");
Of course it won't work within a .war file..
> > Something like calling
> > ServletConfig.getInitParameter("docBase"), but something that's standard,
> > and that does not require me to specify the path explicitly in a
> > configuration file?
> >
>
> You are starting from an incorect assumption, that there *is* such a thing
> as a portable "directory path" to a web application. It is entirely legal
> for a servlet container to run a web application directly from a WAR file
> (in which case there is no expanded directory), or by storing its static
> resources in some other sort of structure (such as being BLOB objects in a
> database).
Most websites are not static. Users publish content, for example, and
the logical place for that content to be stored is on the filesystem
inside the webapp, not in a database. So for many, or not most,
websites, the notion that a website can be kept in a .war is not
practical.
I'd be interested to know if there is a solution to this. Perhaps the
filesystem could be mapped to a JNDI context, which could be made into a
"virtual filesystem" inside the webapp?
--Jeff
> > TIA,
> >
> > Rick
> >
> >
>
> Craig McClanahan
>