File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply 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: 12612
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: 12612
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: 12612
That is JSP.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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.
[Thumb - 1.jpg]
 Filename 1.jpg [Disk] Download
 Description Product Image with description
 Filesize 30 Kbytes
 Downloaded:  21 time(s)

 
jQuery in Action, 2nd edition
 
subject: View the images as four per row instead of long row that is never ending
 
Threads others viewed
Unable to find specific product
Show only one record instead of specific record when onclick
Problems when viewing specific description when search
Displaying images dynamically from database
Product Details unable to add to shopping cart
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture