wood burning stoves 2.0*
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: 166

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
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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to acess file outside a War file.
 
Similar Threads
how to deploy?
how many portlet I can put in one *. war file
WAS 5.1 Classloaders
Can't deploy war file outside of [tomcat]/webapps
best place to put configuration properties.