You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Connie Chan <cc...@drfirst.com> on 2001/04/18 22:57:43 UTC

Problem response.sendRedirect

Hi,

Does anyone know what response.sendRedirect is supposed to behave?  I'm
developing an object to detect if the session is valid.  All my servlets
would call the function from this object (let say
sessionChecker.checkSession(request, response) ) to check if a valid
session exists.  If there is no session, I call
response.sendRedirect("login.jsp") in this session checker object.
However, I find out that when this line gets executed, the response does
not get redirected right away.  Although I put " return; " after calling
sendRedirect, the handler would return back to my servlet.  My servlet
would continue to execute the logic.  At some point, the response would
get redirected.

Also, in the jsp case, I use jsp:include at the beginning of my jsp
page.  I then check the session by calling the session checker object.
If there's no valid session, the response should get redirected.
However, my jsp page would throw an exception about
java.lang.IllegalStateException: Response has already been committed.  I
need to use include directive, instead of using jsp:include.  Once I
change it, my jsp page works.  But I do need to provide an argument for
the page included.  How should I do it without calling jsp:include?
Please help.



Thanks,
Connie