aspose file tools
The moose likes Servlets and the fly likes How to acess file outside a War file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to acess file outside a War file." Watch "How to acess file outside a War file." New topic

How to acess file outside a War file.

Hasif Subair

Joined: Aug 12, 2009
Posts: 24

When users upload images, I am saving it to an external folder(outside deployed WAR file). I need some way by which i can access these files and display it on the webpage. How can this be done.
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

The user uploaded files can be displayed in a web page using servlet/jsp by reading the physical file (FileReader etc). Then the bytes of the read stream can be written into the output stream of servlet to display the read files in web page.

BufferedReader in = new BufferedReader(new FileReader("absoulte path name"));

No pain, No gain.
OCJP 1.6
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Just be sure to release the file after you read it. Or your app will have a lot of memory problems.

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
I agree. Here's the link:
subject: How to acess file outside a War file.