Asiri Liyana Arachchi
Asiri Liyana Arachchi

Reputation: 2673

Struts logic tag with session variables

Following code prints 0 values in the table column. But it is not supposed to print since in the logic equal it checks whether the value is 1.

<logic:equal name="humpRoadFlag" value="1" scope="session">
           <td title='<bean:message key="prompt.block_to" />'><%= session.getAttribute("humpRoadFlag") %></td>

</logic:equal>

Any idea?

Upvotes: 0

Views: 1214

Answers (2)

Nor Leyva L&#243;pez
Nor Leyva L&#243;pez

Reputation: 141

You can skip using the logic tag using java code in the JSP , if still printing '0', the value assigned to humpRoadFlag in session , is not what is intended to be.

 <%=String humpRoadFlagValue =(String)session.getAttribute("humpRoadFlag");
    if(humpRoadFlagValue.compareTo("0")!=0){%>
    <td title='<bean:message key="prompt.block_to" />'><%=humpRoadFlagValue %></td>
<%=}%>

Upvotes: 1

Asiri Liyana Arachchi
Asiri Liyana Arachchi

Reputation: 2673

This should be included in the jsp page.

 <%@ taglib uri="/WEB-INF/taglib/struts-logic.tld"     prefix="logic" %>

Upvotes: 1

Related Questions