tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From A Yang <ayang...@yahoo.ca>
Subject response.sendRedirect vs. requestDispatcher.forward
Date Tue, 29 May 2001 14:20:34 GMT
Hi All,

Does anyone know offhand whether the Java Servlet
specification requires a new HttpSession to be created
when using HttpServletResponse.sendRedirect()?

In a servlet, I was using:

getServletConfig().getServletContext().getRequestDispatcher("/Result.jsp").forward(req,
resp);

at the end of a sequence of pages/servlets, but I
wanted to replace it with

response.sendRedirect("/Result.jsp");

instead. The result page prints out the contents of
several javabeans which are stored in the session.

This worked fine when all I used were
requestDispatcher.forward but with
response.sendRedirect(), all of my session attributes
are gone! In fact, the session id is different after
the sendRedirect.

I'm pretty sure the session is supposed to survive
across any series of GET's and POST's until it is
invalidated explicitly (or timed out).

Any thoughts? I'm using Tomcat 3.2.1

Thanks.

_______________________________________________________
Do You Yahoo!?
Get your free @yahoo.ca address at http://mail.yahoo.ca

Mime
View raw message