Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sendRedirect problem

 
Hazel Sisson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"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
 
Hazel Sisson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much, I will give it a go!
Hazel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic