*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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..
 
Similar Threads
Heads First - Web App Deployment - Question 14 (Page 615)
unable to access html in jboss eventhough pdf is accessible!
Opening files from servlets
cannot load property file from WAR
Text file xls to Binary format xls in Java.