tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oscar Moreno <omor...@prosrm.com>
Subject RE: My parameters are lost when storing them in HttpSession using Servlet
Date Fri, 14 Jul 2000 12:56:59 GMT
If cookies are not supported, you should tried encoding your URLs with the
encodeURL() method of the HttpServletResponse interface.
 
I hope this helps.
 
Oscar

 -----Original Message-----
From: Andrew Shiels [mailto:shiels@ssi-schaefer-noell.com]
Sent: Friday, July 14, 2000 3:12 AM
To: tomcat-user@jakarta.apache.org
Subject: My parameters are lost when storing them in HttpSession using
Servlet 



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));
  res.sendRedirect("index.jsp"); 
 
..
..
}
 
My problem is that when I try and access this session information in my
"index.jsp" page, all values are null.
 
<%@ page errorPage = "Error.jsp" import = "java.util.*,
javax.servlet.http.*, javax.servlet.*" %>
<HTML>
<HEAD>
<TITLE>KULIE</TITLE>
</HEAD>
..
<%=session.getAttribute("permission")%>
<%=session.getAttribute("loggedIn")%>

..
</HTML>
 
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. 
 
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:
 
v.jsp
 
<%session.setAttribute("andy", new String ("HELLO!"));%>
<% response.sendRedirect ("w.jsp");%>
 
w.jsp
 
<HTML>
<BODY>
<H1>
<%=session.getAttribute("andy")%>
</H1>
</BODY>
</HTML>
 
This works fine, so my problem only seems related to servlets. 
 
Has anyone any idea on what could possible be causing the problem?
 
Thanks,
 
Andy Shiels
 
 


Mime
View raw message