• Post Reply Bookmark Topic Watch Topic
  • New Topic

Negative step value for <c:forEach> tag

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reverse the list prior to sending it to the JSP.
 
Soumya Bardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
forget the list. I am trying make a drop down menu containing year from 1910 to 1994 in reverse i.e 1994 to 1910 .I am taking input of D.O.B.How do i do this?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's just as easy to generate a list in the controller as it is in the JSP. Doesn't really make a difference if the for-loop is in the controller or the JSP, does it?
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Soumya Bardhan wrote:forget the list. I am trying make a drop down menu containing year from 1910 to 1994 in reverse i.e 1994 to 1910 .I am taking input of D.O.B.How do i do this? :confused:

Assuming you want to begin at 1994 and count backward 84 steps, what would happen if you did the following:
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Math can be fun!

In the general case, lists are created in controllers and passed to the JSP. In this case, because the list is merely a general numeric sequence that can be expressed as a numeric expression, it could be done directly in the JSP. I tend not to do that for consistency if nothing else.
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Math can be fun!

In the general case, lists are created in controllers and passed to the JSP. In this case, because the list is merely a general numeric sequence that can be expressed as a numeric expression, it could be done directly in the JSP. I tend not to do that for consistency if nothing else.

I agree completely, but since that point had already been made, I thought I would just point out the simplicity of the solution which was being overlooked - as I think the OP was missing the forest for the trees
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
 
Soumya Bardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks every one.And yes Maths is definitely fun.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!