Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JSTL doubts (c:if)

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:
I have a JSP Page with following code:

To not mix Java code with HTML, I am beginning to use the JSLT from the Jakarta Project. My page was thus:

Now the code does not function as before. The content inside of tag c:if does not appear no way. I tried to make test="${!empty stringSearch}" but the same thing happened. How I must "translate" the condition of the original code for tag?
Thanks,
[ February 19, 2003: Message edited by: Rafael Afonso ]
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem #1 is that, while you change the local reference variable "stringSearch", you don't actually change the page-scoped attribute of the same name (as in JspContext.setAttribute(.., PAGE_SCOPE)). Hence the JSTL cannot see your change and will see an empty String.
Problem number two is probably that the JSTL EL does not have an operator "&&". Replace it by "and". The up-and-coming JSP 2.0 will support "&&", though; a boon for Java geeks
In any case, this is not very idiomatic; I would suggest you replace the code by something likeIf you really want the stringSearch variable, useBy the way, in JSP 2.0 you'd simply sayHTH
- Peter
[ February 19, 2003: Message edited by: Peter den Haan ]
 
Rafael Afonso
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter:
It works! Thanks for lesson. What means HTH?
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hope This Helps
- Peter
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a quick clarification - JSTL 1.0 supports the 'empty' keyword, so you don't have to wait for JSP 2.0 to use it.
JSP 2.0's major new feature is that it lets you use the EL anywhere -- in template text, custom tags, and so forth.
"HTH"
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shawn Bayern:
Just a quick clarification - JSTL 1.0 supports the 'empty' keyword, so you don't have to wait for JSP 2.0 to use it.

D'oh. That's what you get for using the public draft of the JSTL spec instead of the final thing
- Peter
 
reply
    Bookmark Topic Watch Topic
  • New Topic