I don't know which engine you're using, but it's worth knowing that
recent JRun builds strip cookies (and I guess other) headers when
sendRedirect is called. They don't consider this a bug, but I do.
The workaround is:
resp.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
resp.setHeader("Location", location);
instead of resp.sendRedirect(location).
Rod McChesney, Korobra
XJ: Micael K�llman wrote:
>
> Hello
>
> I wonder what really happens when you do a call to the
> HttpServletResponse.sendRedirect() method. I happened to use both
> sessions and normal cookies in a servlet before doing a sendRedirect(),
> and to my surprise it worked. I guess I shouldn't have been surprised
> since every response has to use the HTTP-protocol, but I still wonder
> where the redirection actually takes place. Is it a special header?
> Could it be a meta-tag in the body of the response? I am just guessing
> here. Is there any risk that it could be implemented differently in
> different servers / servlet engines? Would the server influence the
> behaviour in any way?
>
> In a posting a few days ago I saw that it was possible to specify a
> target-frame by setting a header; can sendRedirect() be used in any
> other special ways that might be useful?
>
> Samplecode with Cookie and sendRedirect()
> Cookie userLevel = new Cookie("level",5);
> userLevel.setMaxAge(-1);
> res.addCookie(userLevel);
> res.sendRedirect("http://domain/servlet/somewhere.html");
>
> TIA
> /Micael
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html