jstl compare two strings how?

i need to compare one session varable with on jstl varable, they are strings... how do i re-write the following?<c:when test="<%= session.getAttribute( "userName" ) %>.equals(${emp.ename})">
[266 byte] By [h1400046a] at [2007-11-26 16:05:01]
# 1

<c:when test="${sessionScope.userName == emp.ename}">

yep, they we're equal

</c:when>

The sessionScope isn't even necessary as JSTL will search the different scopes for the value, but the above will avoid name clashes when you have a userName attribute in two different scopes.

gimbal2a at 2007-7-8 22:27:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

It can be done by using following:

<c:choose>

<c:when test="${sessionScope['userName'] eq emp.ename}">

<!-- do sothing here -->

</c:when>

<c:otherwise>

<!-- do something else -->

</c:otherwise>

</c:choose>

However, there is an alternative way to achieve more sophisticated requirement.

New JSTL 1.1 solution:

<!-- say you want to search just a portion match -->

<c:choose>

<c:when test="${fn:contains(sessionScope['userName'],emp.ename)}">

<!-- sessionScope['userName'] was partially matched -->

</c:when>

<!-- ... etc -->

</c:choose>

Refer more from the article which I wrote:

http://avatar21.superihost.com/index.php?entry=entry070124-185808

Regards,

Avatar Ng

Avatar_Nga at 2007-7-8 22:27:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...