• Post Reply Bookmark Topic Watch Topic
  • New Topic

c:if condition on null attribute

 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My attribute gets set to Null, and then I need to use the value of this attribute in the If condtion to execute certain code.


The problem here is that it throws an error "The function getAttribute must be used with a prefix when a default namespace is not specified".
Could you please advise on this.
Also, if not <c:if>, what can be the condition for <c:when> in <c:choose>.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65529
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using getAttribute() with the EL and JSTL?

Also, is there a reason you are not using the empty operator?

 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And here it is without scriptlet expressions.
<%= request.getAttribute("foo") %> is equivalent to ${requestScope.foo} or in most cases just ${foo}
It makes for a much more readable page.
Also swapped two if statements to a if then else equivalent of choose when otherwise for clarity.
Your 'else' condition looked a little confused, so I just stated the obvious.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!