Re: Display images on a webpage
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Fri, 10 Oct 2008 22:45:41 -0400
Kevin Moseley wrote:
I apologize for not being clearer. I am new to java,struts, tomcat, and hibernate. I guess I am curious as to which is better, storing images in a database or using the file system and storing the file information in the database. What I want to do is have users upload photos and when they open their profile they can view the files they have uploaded. I am using struts and hibernate and I don't know how to pull multiple images in the jsp.
What is the best practice for uploading and viewing images? I have googled it and it seems the consensus is to store files on the file system and use action files to display the images using input streams to display the images. What is causing me problems how to display on the page load.
When I meant reload is if upload a new .war file doesn't is overwrite the folder when I restart tomcat and if my images were in there they would be lost.
You can store the images 3 places:
a) database
b) file system in directory served by Tomcat
c) file system in directory not served by Tomcat
It can be implemented by:
a) have your pages generate <img src="ImageServlet?imgid=177">
have ImageServlet set MIME type appropriate, retrieve BLOB from
database and write to output
b) have your page generate <img src="images/img177.jpg">
c) have your pages generate <img src="ImageServlet?imgid=177">
have ImageServlet set MIME type appropriate, read image from
file system and write to output
Which one to chose ?
#b has some problems:
- redeployment that you mention
- lack of security by user
so it is either #a or #c.
It is a well known discussion.
Many people swear that images in the database will kill the
database performance.
And putting images in an Access 95 database on Windows 95 on
a 150 MHz Pentium box indeed did kill database performance.
But a few things ha changed in software and hardware since then.
With a good database system then there should not be any problem
having images of small-medium size in the database.
I once made som tests to verify and performance was OK.
So I will suggest going for #a.
Arne
.
- References:
- Display images on a webpage
- From: Kevin Moseley
- Re: Display images on a webpage
- From: John B. Matthews
- Re: Display images on a webpage
- From: Msj121
- Re: Display images on a webpage
- From: Kevin Moseley
- Display images on a webpage
- Prev by Date: Re: Storing data periodically on remote server
- Next by Date: Re: What a pity that Java not Include Operators overloading,Wake up
- Previous by thread: Re: Display images on a webpage
- Next by thread: Unicode support
- Index(es):
Relevant Pages
|