This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Can't get familiar with Expression Language  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear forum users,
I wish to understand why the expression <c:if test="${!empty taskVersion}"> in the following code returns always true



thanks for any suggestion!
 
Marshal
Posts: 67163
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not enough info. What is taskVersion and how is it created?

Also, mixing the EL with scriptlets is a recipe for disaster. The JSTL and EL are meant to replace scriptlets and Java code in a JSP -- they are specifically designed not to work together.
 
Renato Bobbio Calogero
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply . I'll try to explain myself better. I am trying to include a jsp in another one, and I wish to use the <jsp:useBean> tag in to let my first jsp pass a PcTask object , which details should be details in my "son" jsp.

How should I do that ? I think I should put that object in the session scope with something like :



And I supposed that, to retrieve my object in my "son" jsp , included in my first one , the following


and then I should be able to access to the attributes of my PcTask object ( for which I already defined accessors -getters and setters- for the fields I'm trying to retrieve )



which taskType is one of the PcTask's field , which got a getTaskType() method.

Am I doing this wrong ?

Thanks a lot for any hint !
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"tasktype" is not an attribute declared in scope. It is a property of a bean declared in scope.
Just because you have got a "useBean" tag on your page, doesn't make that bean anything special.

try: value="${task.taskType}"
 
Renato Bobbio Calogero
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for your answer. It was clearifying. I have to deal with inherited code, so I can't go too much off path, even if I know there are many ways to do this better.

Just to be clear, as you said my attribute is not in scope,

but if I define



and the in my jsp



I should see my variable ...

then I did this, because I tried as you said but it did not worked just like that ... so I did



maybe it's not smart... but it is working fine...
thank you so much again, You gave me the correct hint...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!