View the images as four per row instead of long row that is never ending
Loh Peggie
Ranch Hand
Joined: Jul 09, 2009
Posts: 51
posted
0
Hey guys you guys did great help for me in displaying images otherwise my page would only be a blank one. Great thanks to you guys
However the problem is I would like to display the images as four by four instead of never ending. Could you guys help me with it? Thanks
Hope to receive you guys reply soon
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12612
posted
0
While I shudder at the wanton use of scriptlets, seems like just keeping a counter and writing a break tag every four pictures would do the trick.
Loh Peggie
Ranch Hand
Joined: Jul 09, 2009
Posts: 51
posted
0
Hey do you mind explaining more cause I dont seem to understand it.
Thanks
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12612
posted
0
I'm not sure which part you don't understand--keep a counter, increment it for every row, when it's a multiple of four output a break tag.
Roberto Hernandez
Ranch Hand
Joined: Apr 29, 2009
Posts: 33
posted
0
As a good coding practice, try to minimize the use of scriptlets inside JSPs and definitely stay away from JDBC stuff inside Java Server Pages. All this code should be inside a Servlet or better yet a Java Bean.
To your question,
try using JSTL to iterate over your collection, see the example below
Notice the use of varStatus. This would be your actual counter that will be incremented by one(default) on each iteration. If you need 4 records per row you would need to
check for the remainder of the counter by 4 (status.count % 4 == 0). If that's the case, end the row </tr> and start a new one <tr>. That will guarantee that you only
have 4 records per row and will give you a much cleaner code
Loh Peggie
Ranch Hand
Joined: Jul 09, 2009
Posts: 51
posted
0
thanks
But can yoyu explain it in the form of jsp/ servlets form cause I dont quite understand it from the one you use in the codings.
Sorry
Your use of scriptlets is technology that was discredited over 6 years ago. Roberto has shown you the modern way to write JSP. I'd find a modern tutorial and come up to speed if I were you.
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? Thank You for your help all this while. Ans do you guys also know how to display out the image with the specific details like there is image and beside the image there is prodname,prodcolor....
My database is called: file_image
My attribute are
id(int)
uploaded_file(blob)
file_name(varchar)
The attachment is an example of how my desired output.
Really, really thanks you guys for your help
The above code only display out the path of imags, however the one i need is to display out the real images with all the details.