• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

s:if Question

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The condition goes inside the brackets. try
 
David Ogasawara
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic