*
The moose likes Servlets and the fly likes Uploading, saving and displaying images using servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Uploading, saving and displaying images using servlets" Watch "Uploading, saving and displaying images using servlets" New topic
Author

Uploading, saving and displaying images using servlets

Siddharth Ahluwalia
Greenhorn

Joined: Mar 06, 2009
Posts: 1
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

Joined: Jan 10, 2002
Posts: 60782
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Uploading, saving and displaying images using servlets
 
Similar Threads
protect images in html
Send images as zipped(compressed)
Saving a file to clients machine
Saving gif file from inputstream
Saving image to BD