• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equivalent EL instead of scriplet

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can I replace the following scriplet with the help of c:if and EL

<% if(searchResults.size() == 0 && request.getAttribute ("firstLoad") == null ) { %>

..my code

<% } else { %>
...my code
<% } %>

Thanks
Imad
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give it a shot and see how close you can get.

Some notes:

  • searchResult will need to be a scoped variable rather than a scripting variable
  • the JSTL 1.1 fn:length() EL function can be used to obtain the size of a collection
  • the empty operator will check for null or empty
  • in order to implement an "else" condition, you'll need to use <c:choose> rather than <c:if>
  • it is assumed that you are using JSTL 1.1 and JSP 2.0


  • [ October 03, 2006: Message edited by: Bear Bibeault ]
     
    Muhammad Imad Qureshi
    Ranch Hand
    Posts: 238
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hey bear thanks a lot. i was just too much in a rush. i did it. thanks
    this is what i did. I thought i cannot use && and compare null in EL but it turns out i can

    <c:choose>
    <c:when test="${empty searchResults && firstLoad == null }">
    Addresses Not Found ! </span></p>
    </c:when>
    <ctherwise>
    ....html to generate and display table
    </ctherwise>
    </choose>
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic