0

I have JSF 1.2 based Servlet. Am setting Session attributes in bean of my Servlet. Bean is in Request scope. In this Servlet there is a link. When this link is clicked it calls another Servlet. This 2nd Servlet is not JSF based. It just contains one JSP page to display data. Am trying to display data in this JSP by retrieving Session attributes set in the 1st Servlet. But, the data that am getting in JSP page is null. Session ID is same in both the Servlets. I have below relevant code in my JSP page.

<%@page language="java" session="true" %>
<%@page session="true" %>
 session = request.getSession();
 String userName = (String)session.getAttribute("uname");

Below is the way am setting Session attributes in bean

HttpSession session = null;
    HttpServletRequest req = null;
    req = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
    session = req.getSession();
session.setAttribute("uname", this.uname);
Vikas V
  • 3,176
  • 2
  • 37
  • 60

1 Answers1

1

Try to use EL to retrieve your session attributes. For e.g.:

${sessionScope['uname']}
Paulius Matulionis
  • 23,085
  • 22
  • 103
  • 143
  • I tried and and . None of them worked! – Vikas V Oct 17 '12 at 11:54
  • One more thing. Session attribute is set in the bean when some action is called. After this a User has many pages to navigate. Finally he will end up in 2nd Servlet where in the Session attribute being set in 1st Servlet's bean is being tried to display in a JSP page – Vikas V Oct 17 '12 at 11:57