permaculture playing cards*
The moose likes Servlets and the fly likes FileInputStream within a servlet - Path Question.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "FileInputStream within a servlet - Path Question.." Watch "FileInputStream within a servlet - Path Question.." New topic
Author

FileInputStream within a servlet - Path Question..

Brian Quinn
Ranch Hand

Joined: Dec 23, 2003
Posts: 32
I have a servlet within a web app, that loads a .xls file. I put the .xls file in the .war that contains the servlet, but I can not get the servlet to find the file . So my question is :
How do I use a relative path to find a file that is in a .war file from a servlet within that .war file ? Is it even possible ?
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
I think there are issues with getting the path from a war file. Normally I would use:
String realPath = application.getRealPath("/path/from/webroot/file.xsl");
This gives you the absolute file path; however, this used to not work when you had your app in a war file. I hardly ever deploy with a war file, so I am not sure of the solution (if the above does not work).
Hope this helps.


- Chris Stehno, SCPJ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileInputStream within a servlet - Path Question..