This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "sendRedirect problem" Watch "sendRedirect problem" New topic
Author

sendRedirect problem

Hazel Sisson
Greenhorn

Joined: Feb 12, 2002
Posts: 17
Hello,
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 -> loginservlet.java -> 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,
Hazel
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.
regds.
- madhav


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Hazel Sisson
Greenhorn

Joined: Feb 12, 2002
Posts: 17
Thanks very much, I will give it a go!
Hazel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sendRedirect problem