File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Using a jsp's local variable in 'c:if' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using a jsp Watch "Using a jsp New topic
Author

Using a jsp's local variable in 'c:if'

vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
I am new to JSTL. Is there way to use a jsp local variable inside a <c:if> or <c:when>. I will give an example for my question:

test.jsp


I have tried this, and it does'nt work. Is there a way to do something like this?

Thanks for any suggestions
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

The JSTL and EL operate upon scoped variables, not scripting variables. In general it is considered poor practice to mix and match them. Either use scriplets or use JSTL, not both.

If you insist, you can create scoped variables from any scripting data with the PageContext.setAttribute() methods.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
I want to learn EL and JSTL and stop using scriptlets in my jsp's.Which book do you recommend JSTL and EL?
[ August 15, 2006: Message edited by: vishwanath nadimpally ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Nothing beats the JSP and JSTL specifications. Links can be found in the JSP FAQ.
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
thanks.
 
jQuery in Action, 2nd edition
 
subject: Using a jsp's local variable in 'c:if'