JProfiler
Get rid of your performance problems and memory leaks!
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of JBoss AS 5 Development this week in the JBoss forum
or Spring Dynamic Modules in Action in the Spring forum!
Reply locked JavaRanch » Forums » Java » JSP
 
RSS feed
 
New topic
Author

Displaying images dynamically from database

Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Messages: 50

Hey guys do you know whether is there any samples of displaying 100 images dynamically from database(Sql query browser) on the jsp path.
My data type for image is called 'varchar'.


In here I had declare a folder in my web content called images and there is a sub folder called Beanie with all the image im it like 1120.jpg..... and in my database i enter the record for image is called 1120.jpg. So that the string can be get

Thanks

This message was edited 1 time. Last update was at by Bear Bibeault

Jeanne Boyarsky
internet detective
Sheriff

Joined: May 26, 2003
Messages: 16918

Loh,
Welcome to JavaRanch!

It's good practice to keep the JDBC code out of the JSP. So you would write the JDBC code to get a list of image names and stick them in a request attribute. Then the JSP would loop through that attribute list and display them.

Are you having trouble with a specific part of the code you posted?

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]

"The set strikes me as something like the set of potatoes, radishes, farming, and lunch. " - a colleague's way of comparing both overlapping and disparate groups. made me laugh and thought of the ranch
Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Messages: 50

Icic. Thanks for welcoming me

Oh ya but i did put the jdbc above the jsp as for the looping is it it indicate at the jsp paga or?

My code is for the project page i am doing is:


Thanks Hope to receive your reply soon!
pravin shirke
Ranch Hand

Joined: Apr 05, 2008
Messages: 114

hi loh,
what you can do is just put a while loop inside your for loop and iterate over the result set.
your code slightly modified ADDED while loop
eg.

SCJP1.5 - 88%.<br />SCWCD1.5 - Preparing.
Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Messages: 50

Hey great thanks to you guys. I'll try it asap


Thanks
Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Messages: 50




Hey is it we have to add something like <% around here cause it seems to be in error.
Thanks
pravin shirke
Ranch Hand

Joined: Apr 05, 2008
Messages: 114

hey loh,
Oops sorry for the inconvience, actually i copied the code of yours and pasted i guess it did not paste properly you should write the img tag for that
e.g:

i guess this should solve the problem..
hope it works
bye

SCJP1.5 - 88%.<br />SCWCD1.5 - Preparing.
Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Messages: 50

Hey hey I try the codes that you gave me but it ends up no record.

Hope to receive your reply soon
Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Messages: 50

Hey sorry I have decided to stick to the String Instead of blob. Sorry.

Oh ya I had made a mistake, i had change to a page whereby all the images is display out at one time. When I click on a certain picture it will hyperlink to the description of that certain product .Example: when click on the Yellow beanie it will go to the specific description of the product and when click on pink beanie if will go to the specific description of the pink beanie

However I could not hyperlink it.

What happen?


Thanks
[Thumb - image.jpg]
 Filename image.jpg [Disk] Download
 Description Print Screen of the product so that when hyperlink can go to spceific description:)
 Filesize 30 Kbytes
 Downloaded:  29 time(s)

This message was edited 1 time. Last update was at by Loh Peggie

Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Messages: 50

Hey guys do you have any example to display blob images store in database(my sql server) and dispaly it on jsp whereby they call the images from the servlets and display it on jsp four by four in a row?

And the image can also be display with its details like the prod color, prod name, prod price,etc.

My database is called : save_image

My attributes are:

id(int)
prodname(varchar)----name of image
prodcolor
prodImage(blob)

Thank you
[Thumb - 1.jpg]
 Filename 1.jpg [Disk] Download
 Description Product Image with description
 Filesize 30 Kbytes
 Downloaded:  28 time(s)

This message was edited 1 time. Last update was at by Loh Peggie

Bear Bibeault
Author and opinionated walrus
Sheriff

Joined: Jan 10, 2002
Messages: 35638

There only needs to be one topic discussing this.

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
jQuery in Action
 
 
Reply locked JavaRanch » Forums » Java » JSP
 
RSS feed
 
New topic
IntelliJ open source