Meaningless Drivel is fun!
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


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
Author

How to acess file outside a War file.

Hasif Subair
Greenhorn

Joined: Aug 12, 2009
Posts: 24
Hi,

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: 171

Hi,
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.

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

No pain, No gain.
OCJP 1.6, Liferay Certified Developer 6.1
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.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
 
Have you checked out Aspose?
 
subject: How to acess file outside a War file.
 
It's not a secret anymore!