Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Replace scriptlet on JSP  RSS feed

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi from my action class I am forwarding an arraylist on jsp where I am iterating it I use following scriptlet for it








how can i raplce this scriptlet with some other option like an custom tag or standard tag or something else .... please let me know if you have any idea about it ........


Thanks

Kaustubh
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi from my action class I am forwarding an arraylist on jsp where I am iterating it

I don't see any iteration in your code. But if you want to iterate through a collection, you can use JSTL's c:forEach tag.
 
Devaka Cooray
Marshal
Posts: 5322
575
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is an if-condition as it is shown in your code, you may want to use c:if element of JSTL.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am already using loigc: equal to reaplce the if condition the thing I want to reaplce if fully is that if statement plus the creation of arraylist object and assign values to it... how is done via jsp tags???
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${agedlistofcases}
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here is the iterate code I want to replace it also::::::


 
Devaka Cooray
Marshal
Posts: 5322
575
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Christophe said, use JSTL c:forEach tag for the iteration. For the if conditions, use JSTL c:if together with EL.
For example: <c:if test="${i lte 1}">

Avoid using a iTotalCount variable in the JSP - assign it as a request attribute from the servlet, so you can simply get the value of it from JSP.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working over it thanks everyone..

Kaustubh
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a note:
The c:if tag mentioned earlier does not have an else clause.

If you want to do if-then-else, look at the c:choose tag which holds the children c:when and c:otherwise.

There is also the tertiary operator in EL ${some-condition ? true-value : false-value}

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!