> Hi Kedar,
>
> the purpose of ServletContext.getResource() *is* to
> provide access to resources stored in the webapp's
> context root. "context root" and "docroot" are used
> synonymously.
I'll take "conflating vocabulary for $100 Alex!".
When *I* see "docroot", I'm thinking the docroot of the virtual host, which is not necessarily the same as the context root of the application.
Now, if you want to get access to a File that is deployed in a WAR, that's a different problem.
This can easily be done.
What you are looking for is:
String pathString = ServletContext.getRealPath("/index.html");
Could easily return: "C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\yourwar\index.html"
That will locate a bundled file within the web app. It will also locate files THAT DO NOT EXIST. When that happens, it will return a path where it SHOULD be if it DID exist.
But, to be clear, this is relative to the executing WAR and has nothing to do with the actual "docroot" of the virtual server.
Just want to be clear on the vocabulary here.
[Message sent by forum member 'whartung' (whartung)]
http://forums.java.net/jive/thread.jspa?messageID=244152