File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes sendRedirect problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "sendRedirect problem" Watch "sendRedirect problem" New topic

sendRedirect problem

Hazel Sisson

Joined: Feb 12, 2002
Posts: 17
what I am trying to do is redirect to a page using sendRedirect(). I am using this method so that the correct URL will be displayed in the address bar, as previously the servlet had changed it.
This is the page sequence:
login.jsp -> -> redirect.jsp -> index.jsp
In redirect.jsp I have put this code:

The aim is for the page to redirect correctly while maintaining the session whether cookies are enabled or not, i.e. I need to encode the URL.
Presently when redirect.jsp is reached the sequence stops and it doesn't redirect. This happens whether cookies are enabled or not. "Loading..." is displayed.
Does anyone have any idea why it stops here?
Thanks very much,
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

"Loading..." is displayed.
Does anyone have any idea why it stops here?

If "Loading..." is displayed, that means your response is committed. Once response is committed, it possible that the app server throws an IllegalStateException.
1. Check your app server log.
2. Add a stmt "<%= response.isCommitted()%> before the redirect to find out if response is committed or not?
3. If you want to add something to the response, maybe you could do it in the other JSP itself, if possible.
- madhav

Take a Minute, Donate an Hour, Change a Life
Hazel Sisson

Joined: Feb 12, 2002
Posts: 17
Thanks very much, I will give it a go!
It is sorta covered in the JavaRanch Style Guide.
subject: sendRedirect problem
Similar Threads
How to acheive Send Redirect in Struts
Shopping carts and sessions and cookies, oh my!
Difference between URLs: /? and /login?
Why get IllegalStateException when redirect in Servlet Filter?