Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

s:if Question

 
David Ogasawara
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to Struts 2 and I'm trying to figure out why my s:if is not working.

If I enter this:

it returns Y.

However, if I enter this:

It returns No.


What am I doing wrong?
[ May 23, 2008: Message edited by: David Martin ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The expressions you are using are OGNL expresssions, not Java expressions. The expression "#{session.admin}" is a valid OGNL expression, while "#{session.admin.trim()}" is not.
 
David Ogasawara
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your assistance. However, I changed the code and it still gives me the incorrect response.



Could the problem be that I'm comparing a String to a char? If so, how is this solved?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The condition goes inside the brackets. try
 
David Ogasawara
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help! I figured out the problem. I initially set the session variable as a String (session.setAttribute("admin", "Y")). Changing it to a char (session.setAttribute("admin", 'Y')) solved the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic