Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

View the images as four per row instead of long row that is never ending

 
Loh Peggie
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey do you mind explaining more cause I dont seem to understand it.
Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is JSP.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Loh Peggie
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
1.jpg
Product Image with description
[Thumbnail for 1.jpg]
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sabarish Jaganathan,
Your post was moved to a new topic.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic