Take the 2-minute tour ×

I am using Struts2. And having trouble in test a String for null or empty. The String is in a loop.

What I have done so far is

in Action class I have a List<User>. User have id and name fields and have getters and setters...

in JSP i am doing like

<s:iterator value="userList" var="user" status="userStatus">
    <s:if test"%{user.name != null && user.name != ''}">
       <!-- Do some thing... -->

Problem is that Its not working :(, I cannot see the names and they are visible if I remove the <s:if> block.

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

Try with this

<s:if test="%{#user.name != null && #user.name != ''}">
   <s:property value="#user.name"/>
share|improve this answer
Thanks! It worked. I am also confused in checking string in Java works in equals(), is it same as != or == in Struts tag in JSP. –  Talha Ahmed Khan Feb 24 '12 at 7:25
add comment

Your Answer


