Advertisement

10.04.2006 at 12:25PM PDT, ID: 22013066
[x]
Attachment Details

Session Variables in Struts

Asked by tmonteit in Java Server Pages (JSP), Java Standard Tag Library (JSTL) & Server Tags

Tags: struts, session, variable

I have an action that loads a session variable.  In my jsp, I want to modify the text depending on my session variable.


---- action --------------
HttpSession session = request.getSession();

if(/* Test for Admin */)){
      debug("isAdmin = true");  // THIS LINE PRINTS, SO I know isAdmin is set.
      boolean isAdmin = new Boolean(true);
      session.setAttribute("isAdmin", isAdmin);
}

--------end action-------

---------jsp -------------
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
...

Welcome
<c:choose>
      <c:when test="${(sessionScope.isAdmin!=null)}">
         Administrator
      </c:when>
</c:choose> <br>

------------------------

Page prints:  "Welcome"  not "Welcome Administrator"

What's the proper way to access my session variables.Start Free Trial
 
Loading Advertisement...
 
[+][-]10.04.2006 at 02:22PM PDT, ID: 17663650

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.04.2006 at 02:23PM PDT, ID: 17663656

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.04.2006 at 02:42PM PDT, ID: 17663794

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.05.2006 at 01:14AM PDT, ID: 17666632

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2006 at 09:12PM PDT, ID: 17712784

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Server Pages (JSP), Java Standard Tag Library (JSTL) & Server Tags
Tags: struts, session, variable
Sign Up Now!
Solution Provided By: muktajindal
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32