Brien,
Thank you! That fixed the problem. I was refering to the servlet using
the URL: http://127.0.0.1:8000/servlet/LoginServlet. Inside the servlet
I was doing a redirect using the following snippet of code:
String url = req.getScheme() + "://" + req.getServerName() + ":" +
req.getServerPort() + "/"+ page;
...
res.sendRedirect(url);
...
getServerName() resolves my localhost to the fully qualified hostname
(including the domain name). Since they were two different URLs, each
were getting their own sessions.
It would be handy if there was some kind of FAQ that had answers to such
questions. I am seriously considering taking up Craig's suggestion for
the automated FAQ.
Thanks again for your help,
Anirban
Brien Voorhees wrote:
>
> I've seen this kind of thing happen when there's a difference in the way the
> URL is specified. For example, if the user goes to
> http://www.acme.com/loginservlet
> and login servlet directs them to http://www.acme.com:80/main.jsp they'll
> probably both be using different sessions (also if one of them is https and
> the other is just http). This drove me nuts on a project I worked on and
> took a while before I was able to figure out what the problem was. Could
> this be what you're experiencing?
>
> Brien Voorhees
>
> ----- Original Message -----
> From: Anirban Sharma <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, October 14, 1999 4:35 PM
> Subject: Session Tracking and GNUJSP?
>
> > I have a LoginServlet where after authenticating my user I do this:
> >
> > HttpSession session = req.getSession(true);
> > User u = new User(id, password);
> > session.putValue("user.id", u.getId());
> > session.putValue("user.email", u.getEmail());
> > session.putValue("user.phone", u.getPhone());
> > session.putValue("user.groups", u.getGroupsAsString());
> >
> > then I redirect the request to the main JSP page where I have a
> > scriptlet like this:
> >
> > <%
> > String id = (String)session.getValue("user.id");
> > String email = (String)session.getValue("user.email");
> > String phone = (String)session.getValue("user.phone");
> > String group = (String)session.getValue("user.groups");
> > out.println("<tr><td bgcolor=\"#E0E0E0\"
> > width=\"25%\"><b>"+id+"</b></td>");
> > out.println("<td bgcolor=\"#E0E0E0\"
> > width=\"25%\"><b>"+email+"</b></td>");
> > out.println("<td bgcolor=\"#E0E0E0\"
> > width=\"25%\"><b>"+group+"</b></td>");
> > out.println("<td bgcolor=\"#E0E0E0\" width=\"25%\"><input type=text
> > value=\""+phone+"\"></td></tr>");
> > %>
> >
> > All these values appear as null in the JSP page. What am I doing wrong?
> > I am using Apache 1.3.9, JServ 1.1 and GNU JSP 1.0.
> >
> > Thanks,
> >
> > Anirban
> >
> >
> ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > FAQs on JSP can be found at:
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> >
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html