Hi,
Thanks to everyone who wrote to help me out with this problem! I have a
working solution that I thought I'd post in case anyone else has the
same trouble, plus a question.
The solution is to use the RequestDispatcher to forward the request. I
had to put the beans into the request first and then forward. My
question is this: why is this required? My understanding after reading
the servlet book and the spec was that all servlets running in the same
"application" had one Servlet context, and that sessions were good
across an application until they timed out or were removed manually. I
assumed that redirects wouldn't affect this. Obviously I was wrong.
Can someone explain to me why this *isn't* the case?
Anyway, here's the code:
SystemBean systemBean = new SystemBean();
String scheme = request.getScheme();
String host = request.getServerName();
int port = request.getServerPort();
systemBean.setServletPath(scheme, host, port);
systemBean.setJspPath(scheme, host, port);
// put the system bean into the servlet context here
getServletContext().setAttribute("systemBean", systemBean);
String user = request.getParameter("user");
String password = request.getParameter("password");
HttpSession theSession = request.getSession(true);
UserBean userBean = new UserBean();
userBean.identity.setUser(user);
userBean.identity.setUserName(user);
userBean.identity.setUserEmail("[EMAIL PROTECTED]");
// put the user bean into the session
theSession.putValue("userBean", userBean);
request.setAttribute("userBean" , userBean);
request.setAttribute("systemBean" , systemBean);
String forwardTo = "/jsp/Here.jsp";
System.out.println("Forwarding to " + forwardTo + "...");
RequestDispatcher rd =
getServletContext().getRequestDispatcher(forwardTo);
rd.forward(request, response);
===========================================================================
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