aspose file tools*
The moose likes JSP and the fly likes equivalent EL instead of scriplet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "equivalent EL instead of scriplet" Watch "equivalent EL instead of scriplet" New topic
Author

equivalent EL instead of scriplet

Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 238
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

Joined: Jan 10, 2002
Posts: 61433
    
  67

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 ]

    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Muhammad Imad Qureshi
    Ranch Hand

    Joined: Sep 13, 2005
    Posts: 238
    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>
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: equivalent EL instead of scriplet