Jstl <c:if>

G

GuyBrush Treepwood

I'm trying to use the jstl tags in my struts application.

web.xml
__

<taglib>
<taglib-uri>/c-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
</taglib>


Main.jsp
__

<%@ taglib uri="/c-rt" prefix="c" %>

(...)

<logic:present name="accountBean" scope="session">
<c:if test="${sessionScope.accountBean.authenticated != true}">
<html:link page="/service/signonForm.do">Sign On</html:link>|
<html:link page="/service/newAccountForm.do">Register</html:link>
</c:if>
</logic:present>


I'm sure there is an accountBean in the session, and that the
authenticated propery is false, but the links are not displayed. What's
wrong with my code? I just can't see it.
 
T

Tim Slattery

GuyBrush Treepwood said:
I'm trying to use the jstl tags in my struts application.

web.xml
__

<taglib>
<taglib-uri>/c-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
</taglib>


Main.jsp
__

<%@ taglib uri="/c-rt" prefix="c" %>

(...)

<logic:present name="accountBean" scope="session">
<c:if test="${sessionScope.accountBean.authenticated != true}">

I think the problem is in the above line. Don't explicitly refer to
the scope, code it like this:

<c:if test="${accountBean.authenticated != true}">

The JSTL logic will find accountBean, regardless of its scope.
 
G

GuyBrush Treepwood

I think the problem is in the above line. Don't explicitly refer to
the scope, code it like this:

<c:if test="${accountBean.authenticated != true}">

The JSTL logic will find accountBean, regardless of its scope.
Tried that, still doesn't work.

I added a <c:eek:ut value="${accountBean.username}" /> to test, and it seems
the ${..} is not interpreted. It just prints ${accountBean.username}
litteraly on the screen.
 
A

Amit Chatterjee

GuyBrush said:
Tried that, still doesn't work.

I added a <c:eek:ut value="${accountBean.username}" /> to test, and it seems
the ${..} is not interpreted. It just prints ${accountBean.username}
litteraly on the screen.

Your problem has to do with you using

<taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>

instead of

<taglib-location>/WEB-INF/tld/c.tld</taglib-location>

The rt TLD does not support EL.

--
**********************************************************
* Amit Chatterjee amit.chatterjee AT quik-j DOT com *
* http://www.quik-computing.com *
* QUIK Computing - Home of the Open Source Contact Center*
**********************************************************
 
A

Amit Chatterjee

GuyBrush said:
Tried that, still doesn't work.

I added a <c:eek:ut value="${accountBean.username}" /> to test, and it seems
the ${..} is not interpreted. It just prints ${accountBean.username}
litteraly on the screen.

Your problem has to do with you using

<taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>

instead of

<taglib-location>/WEB-INF/tld/c.tld</taglib-location>

The rt TLD does not support EL.

--
**********************************************************
* Amit Chatterjee amit.chatterjee AT quik-j DOT com *
* http://www.quik-computing.com *
* QUIK Computing - Home of the Open Source Contact Center*
**********************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top