?
Solved

Using thumbnail images in jsp?

Posted on 2006-05-16
11
Medium Priority
?
421 Views
Last Modified: 2008-03-06
Hello,

In my java web application, I will have a number of images stored on the server and wish to display these as thumbnails in a .jsp. Allowing the user to click on the thumbnail to display the full-sized image in a new browser window.

The number of images on the server will be increasing on a regular bases.

I was trying to plan how to approach this, and wondered if anyone could offer some advise?

With the image number increasing on the server, should I thinking of creating a permanent thumbnail of each and display these in the jsp. Even though creating a thumbnail can be an expensive exercise.

Are there other approaches? Should I be limiting the number of thumbnails displayed on each page?

Thanks
0
Comment
Question by:AntoniRyszard
  • 5
  • 4
  • 2
11 Comments
 
LVL 1

Expert Comment

by:d_g_watson
ID: 16695652
You could create the thumbnail the first time the image is displayed and store it on disk. The next time the thumbnail page is displayed, the image will already exist and will not have to be generated - so the expensive part is only done once per image. I've done something similar to this and thought it worked quite well.

I would limit the number of thumbnails on the page depending on the size of the thumbnail images, and the potential for a particular set to grow.

0
 
LVL 30

Accepted Solution

by:
Mayank S earned 200 total points
ID: 16697096
Basically you can still show it as a "thumbnail" by just specifying a smaller size for the image in the <img> tag. When he clicks on it, let it open full-size (remove the width and height from the <img> tag so that the original size comes).
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16697098
(in that case you don't need to create a new thumbnail, you use the existing image as a thumbnail by showing it in a smaller size)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:d_g_watson
ID: 16698839
That will cause the full size image to be downloaded to the browser. The browser will then scale the image for display. The object here is to reduce the amount of data being transferred from the server.

Please correct me if I'm wrong.
0
 

Author Comment

by:AntoniRyszard
ID: 16702429
Thanks

Could I ask when creating the thumbnail images, which java classses you used.

0
 
LVL 1

Expert Comment

by:d_g_watson
ID: 16702557
I used the Java 2D API, but I don't have a lot of experience with it. I used the technique described on this forum post:

http://forum.java.sun.com/thread.jspa?threadID=522483

Note: this technique will not work on a headless system. There are probably ways to change it to work in such an environment, but I didn't look into that as it wasn't a problem for me.

0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16706550
>> That will cause the full size image to be downloaded to the browser

True. But it saves you from creating thumbnails for new images everytime. Otherwise, of course, you can create a file-monitor for a directory (which contains the actual images) so that whenever it recognizes new files being put over there, it can raise an event to create a new thumb-nail image out of it using Java image API through scaling.
0
 
LVL 1

Expert Comment

by:d_g_watson
ID: 16708983
You don't even need a file monitor. You know what thumbnails you'll need from the directory containing the actual images. When you're rendering the page you can check if the corresponding thumbnail exists for each image in the actual image dir. If it doesn't, create it. If it does, do nothing.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16709044
The problem with that is that if the thumbnail does not exist, you will be creating it at that time (so the response might be slight slower due to that process because it will involve reading the whole image once). If you have an asynchronous file monitor or batch process kind of thing to sync up images and thumbnails, you can be assured that in 99% of the cases, you will have the thumbnails (unless the image was placed just now and in the millisecond before which the thumbnail got created, you got a request for it).
0
 

Author Comment

by:AntoniRyszard
ID: 16745037
Thanks I have lots to think about.

0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16748626
Sure, take your time.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month16 days, 21 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question