• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

jsp and bootstrap cards problem

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m getting data from data base and showing it in cards
my card alignment is perfect without looping it Im using this logic



it works perfectly 3 cards in a row but in loop whole cards are vertically shown



 
Ranch Hand
Posts: 202
1
Android Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The cards are displayed inside a single loop and every iteration of the loop contains a  <div class="row">.

A solution could be two loops where the outer loop loops i in 0 .. number_of_cards / number_of_cards_per_line times and the inner loop places number_of_cards_per_line cards into a single line.

Another principle problem with your code is the usage of scriptlets that are deprecated. Instead you can use JSTL tags in the given case <c:foreach>. Following code is written from memory and untested:

 
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would have been easier to spot the problem quickly had you just compared the JSP-generated HTML to your hand-written HTML. The browser tools are essential for debugging, be sure to utilize them.

And yeah, Java scriptlets in JSP have been deprecated 22 years. 22 years! There is no excuse for using them in JSP pages at this point (or any point in the past two decades). We often hear: "but I'm just a beginner". If so, learning the correct ways from the start is essential.
 
Saloon Keeper
Posts: 27482
195
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Bear has been awakend. Scriptlet users beware!

Seriously. One of the worst things about the Internet is how ancient and obsolete information propagates itself long after it should have vanished. Stuff like Scriptlets, using Class.forName() with database drivers, etc.

So listen to the Bear.

And please, Obaid, don't put so many blank lines in your code samples. It makes them very difficult to read. Blank lines are supposed to do just the opposite. When used sparingly.
 
obaid abbassi
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the code for my servelet


now my question is instead of using scriplet tag I want to get this in JSTL
I m using to get
 
Roland Mueller
Ranch Hand
Posts: 202
1
Android Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THe forEach loop may also use attributes from sessionScope that are accessed by expression language (EL) expressions:

 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic