aspose file tools*
The moose likes JSP and the fly likes View the images as four per row instead of long row that is never ending Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "View the images as four per row instead of long row that is never ending" Watch "View the images as four per row instead of long row that is never ending" New topic
Author

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
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: 12617

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
Hey do you mind explaining more cause I dont seem to understand it.
Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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
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
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
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That is JSP.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Posts: 51
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.



[Thumbnail for 1.jpg]

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Sabarish Jaganathan,
Your post was moved to a new topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: View the images as four per row instead of long row that is never ending