• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with JSTL tags, c:when

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me form my JSTL tags correctly... I couldn't found anything that relates to my problem.




I need to make a logical condition that when x%10 == 0, it prints a newline (<br>), and when not, it prints a " | ". I'm doing this for pagination. It should look like this...


1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
11 | 12 | 13..........................

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The <c:when> and <ctherwise> tags can only be used within the context of a <c:choose> tag.

But that's not how I'd do it. See my next post for how I'd handle it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Note that I didn't use <cut> to emit 'x'. Since we know exactly what is going to be emitted (numerals) there's no need to use <cut> to HTML-encode the output.

You should use <cut> whenever you do not know whether the text to be emitted needs to be HTML-encoded or not.

(This assumes Tomcat 5 and JSP 2.0, of course).
[ January 20, 2006: Message edited by: Bear Bibeault ]
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault saves the day again! Hoooooraaaay! Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!