This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes using scriptelet in s:if Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "using scriptelet in s:if" Watch "using scriptelet in s:if" New topic
Author

using scriptelet in s:if

D kukreja
Ranch Hand

Joined: Jan 29, 2008
Posts: 39
hi,
I have a value in one of the java veriables in jsp. and I want to use it to compare it with one of the value coming from my action. I know values are same but <s:if> never returns true.
This works:
if(languageSelected1.equals("9")) { %>
<s:if test='key.equals("9")'>
comes here fine.

And same this doesn't work ...if I write it like this
<s:if test='key.equals("<%=languageSelected1%>")'>
never comes here.

I tried to use <s:set to set the value, but that didn't help either. Heres the code with <s:set>
<s:set name="templang" value="<%=languageSelected1%>">
</s:set>
//some code here
I tried follwing and nothing worked
<s:if test='key.equals(#templang)'>
<s:if test='#templang=="${key}"'>
<s:if test='%{#templang == key}'>
<s:if test='%{#templang == "${key}"}'>
is there something wrong with the usage ?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: using scriptelet in s:if
 
Similar Threads
Struts2 test condition in s:if not working
s:if String comparison not working
Struts2: Disable textfield
struts2 struts-tags iteration question
using scriptelet in s:if