tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Shiels" <>
Subject My parameters are lost when storing them in HttpSession using Servlet
Date Fri, 14 Jul 2000 10:14:20 GMT
Tomcat version:        3.1

O/S:                        WinNT 4.0 SP6
JDK:                        Java(TM) 2 SDK, Standard Edition Version 1.3.0

I have a servlet which verifies user login information in a database. If the user is allowed
to login I add some information to the session object and redirect the user to a start page:

public void doGet (HttpServletRequest req, HttpServletResponse res)
           throws ServletException, IOException
  HttpSession session = req.getSession(true);
  session.setAttribute("loggedIn",  new String("true"));
  session.setAttribute("permission",  new Integer(iPermission));


My problem is that when I try and access this session information in my "index.jsp" page,
all values are null, and the session id's are different!

<%@ page errorPage = "Error.jsp" import = "java.util.*, javax.servlet.http.*, javax.servlet.*"


I have no idea what the problem is, and have stripped my code right down to the bare bones
to see if I am making any stupid mistake. 

I also triedgetting the session by using HttpSession userSess = request.getSession(); and
displaying the results this way, but the values a re still null

Also, I have tested the following with  2 jsp pages, where 1 jsp page stores data in the session,
then redirects to another page where the data is printed. The files are as follows:


<%session.setAttribute("andy", new String ("HELLO!"));%>
<% response.sendRedirect ("w.jsp");%>



This works fine, so my problem only seems related to servlets. 

Has anyone any idea on what could possible be causing the problem?


Andy Shiels

View raw message