• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading, saving and displaying images using servlets

 
Siddharth Ahluwalia
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I'm seriously new at this, so sorry for missing something that I should have known

I need to be able to upload images, save them to the server's local file system, not as blobs in a database, and then reload these images into pages upon request. To this I intend to store the paths in a db.

I have uploaded images to the server using the apache commons library, and can even save the files to a folder to disk. Now I don't know how to display these images.
Even more fundamentally, is there a specific location I should be saving to where the applets/JSP pages can read it from? How can I specify a location within webapps own directory?

Anyone who can, please do answer in detail, I'm new to JSP and servlets

Thanks a ton
Sid
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's a good idea to store the files within the folder structure of the web app. That makes it hard to upgrade or redeploy.

Rather, I'd do one of:

1) Set up a separate web context solely for the purpose of serving the files and write the uploaded files there.

2) Store them outside the confines of a web app and write a servlet to stream the to the client upon request.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic