Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to view the image files which are stored on server using servlets

 
Pavan Sankurushetty
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Here is a simple question about Servlets. I have some image files on my server folder. I just want to retrieve or view all the images which are on the server in a web browser using servlets. Uploading service runs perfectly but viewing the files is creating a problem. Please help me out.
Thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the files stored somewhere where a web server can serve them via URL?

If not, you'll need to write a servlet that can read an image file from the disk, set the headers appropriately, and send the image data as the response.

Search this forum for other examples of doing just that.
 
Paul Clapham
Sheriff
Posts: 21572
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Pavan!

You should never assume that a simple question has a simple answer, but in this case what you want is a servlet which will serve an image from the folder where you put the images. Here's an example of such a thing: Image Servlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic