<c:choose>
     <c:when test="${not empty fRoles['manager']}">
        Found formRoles manager
     </c:when>
     <c:otherwise>
        NOT Found
     </c:otherwise>
  </c:choose>

Nadia Kunkov wrote:

Hello,

This is my first try with JSTL and somewhere I'm getting the syntax wrong.  
Could you please help me?
I have a bean called user in the session.  One of this bean's properties is a 
hash map called frmRoles.  I need to go over the hashmap's keys and test if a 
particular key exists.  I'm not getting an error when I run the jsp,  it just 
tells me that this key is not found.  But I can print all the keys so its my 
c:choose   test syntax.  The code that gives me a problem is in bold face.  I 
also would like to ask you to point me to the documentation on the syntax used 
within c:when test.  Is it regular expressions or JSTL syntax?

I'd appreciate any help.

Thanks in advance.

NK

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"; %>
<%@ taglib prefix="c_rt" uri="http://java.sun.com/jstl/core_rt"; %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<html>
<head>
<title>Welcome World!</title>
<html:base/>
</head>
<body bgcolor="white">
<logic:present scope="session" name="user">
<h3>Welcome <bean:write name="user" property="userId"/>!</h3>
<br>
<bean:write name="user" property="userFName"/>
<bean:write name="user" property="userLName"/>
</logic:present>
<logic:notPresent scope="session" name="user">
<h3>Welcome World!</h3>
</logic:notPresent>
<html:errors/> <ul>
<li><html:link forward="logon">Sign in</html:link></li>
<logic:present scope="session" name="user">
<li><html:link forward="logoff">Sign out</html:link></li>
<br>
<br>
<bean:define id="fRoles" name="user" property="frmRoles"/>
<logic:iterate id="element" name="fRoles">
Key is <bean:write name="element" property="key"/> <br>
Value is <bean:write name="element" property="value"/> <br>
</logic:iterate>
<c:choose>
<c:when test="${fRoles['manager'] != null}">
Found formRoles manager
</c:when>
<c:otherwise>
NOT Found
</c:otherwise>
</c:choose>


</logic:present>
</ul>
<img src='struts-power.gif' alt='Powered by Struts'>

</body>
</html>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to