File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes sendRedirect does not execute. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "sendRedirect does not execute." Watch "sendRedirect does not execute." New topic

sendRedirect does not execute.

youngsun lee

Joined: Sep 26, 2003
Posts: 4
To redirect jsp page, i use 'response.sendRedirect(url)'. but this method does not execute. (beside i couldn't meet any excetions.)
i think it may be happened because of using multipart/form-data encoding.

is any help?
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

if you are using multipart in the request, you should still be able to use sendRedirect in the response. Is there any possibility that another JSP may be getting included or forwarded to before the call to sendRedirect? An exception could also cause a forward, but you already said you aren't getting any.

Any chance of looking at a code snippet? (only paste the required code, not all of it, and please use UBB code tags)

Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
you need to explicitly return from the service method after the sendRedirect else the redirect will only take effect after the service method has run to completion (which of course may cause a redirect or forward somewhere else replacing the one you want).

I agree. Here's the link:
subject: sendRedirect does not execute.
jQuery in Action, 3rd edition