aspose file tools*
The moose likes Servlets and the fly likes Need to know the path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Need to know the path" Watch "Need to know the path" New topic
Author

Need to know the path

sreedhar Lackka
Ranch Hand

Joined: Jul 05, 2008
Posts: 154
Hi All,
Thanks.
We are keeping our some static contents on webserver (IHS). and in my java/action file if I want that path what should I do?
I want to know the webserver path.
I tried with contextpath it is giving me appl.server.

Please help me

Regards,
Sree
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You want to get an absolute file system path based on the relative web context path?
If so, you can use ServletContext#getRealPath() for that. Also see the API docs.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If I understand the question correctly, this file is not within the web application's context. It's being served by the web server which sits between the application server and the network. Presumably the two servers are on the same machine, which is why sreedhar thinks this question should have an answer. If they were on different machines, then clearly it wouldn't have an answer, and that suggests to me that there's nothing in the Servlet API which will produce the path.

If it were me I would go back and look for a solution to the unstated problem which didn't require knowing that path. Or I would hard-code the path as an application parameter.
 
 
subject: Need to know the path