Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to acess file outside a War file.

 
Hasif Subair
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 171
Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"));
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just be sure to release the file after you read it. Or your app will have a lot of memory problems.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic