• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accessing files located in virtual server paths

 
El Durango
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi El
Can you please post the error stack you might be getting?
Regards
Maulin
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
El Durango
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim,
I did realize that servletcontext was the best approach.
It's now up and running.
regards,
El Durango
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic