This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes accessing files located in virtual server paths Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "accessing files located in virtual server paths" Watch "accessing files located in virtual server paths" New topic
Author

accessing files located in virtual server paths

El Durango
Greenhorn

Joined: Oct 09, 2003
Posts: 23
Hello this may have already been asked so excuse me for redundancy.
I would like to know how to access a file that is located in a virtual path on the server such as: \WEB-INF\classes\package\classes.cfg
Whenever I try to access it either through the abs path or the relative path I get an IO error.
I have a standalone app that needs to access the file and then communicate with the servlet. I am positive that I have done this before but my brain is so fried right now, I can't see straight
Well I hope someone can help me clear this up,
Im gonna get some dinner maybe that will help
thanks in advance,
EL Durango
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Hi El
Can you please post the error stack you might be getting?
Regards
Maulin
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
use the relative path and pass it to the getRealPath method on the context object to get the full path and then open the file. also check your servlet container is setup to allow reading and writting files in the context by looking at the .properties file in the conf dir and adding an entry if needed.


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
El Durango
Greenhorn

Joined: Oct 09, 2003
Posts: 23
Thanks Tim,
I did realize that servletcontext was the best approach.
It's now up and running.
regards,
El Durango
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: accessing files located in virtual server paths