• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:D

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:D
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey do you mind explaining more cause I dont seem to understand it.
Thanks:D
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is JSP.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
[Thumbnail for 1.jpg]
Product Image with description
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sabarish Jaganathan,
Your post was moved to a new topic.
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic