This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes JSTL doubts (c:if) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL doubts (c:if)" Watch "JSTL doubts (c:if)" New topic
Author

JSTL doubts (c:if)

Rafael Afonso
Ranch Hand

Joined: Jul 16, 2002
Posts: 63
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 ]

=================================<br /> Rafael U. C. Afonso<br /> <a href="http://www.javafree.com.br" target="_blank" rel="nofollow">www.javafree.com.br</a><br />=================================<br /><i>Where is debug?<br />debug is on the table</i>
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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

Joined: Jul 16, 2002
Posts: 63
Peter:
It works! Thanks for lesson. What means HTH?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Hope This Helps
- Peter
Shawn Bayern
Author
Ranch Hand

Joined: May 06, 2002
Posts: 160
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"


Shawn Bayern<br />"JSTL in Action" <a href="http://www.jstlbook.com" target="_blank" rel="nofollow">http://www.jstlbook.com</a>
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL doubts (c:if)