• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't get familiar with Expression Language  RSS feed

 
Renato Bobbio Calogero
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!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
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 !
 
Stefan Evans
Bartender
Posts: 1836
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...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!