File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileInputStream within a servlet - Path Question..

 
Brian Quinn
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic