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

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



 
Bartender
Posts: 224
7
Android Python Oracle Postgres Database 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: 67752
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: 28325
210
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
Bartender
Posts: 224
7
Android Python Oracle Postgres Database 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:

 
Always! Wait. Never. Shut up. Look at this tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic