Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

response.sendRedirect problem

 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to do a simple redirect in a servlet. The code looks like this,

String pagename = "http://yahoo.com";
response.sendRedirect(pagename);

I get a blank page after the servlet runs and there is no error message.
Can someone tell me why this is happening?
Thanks.

Arnold
 
Kalai Selvan
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Looking at the two lines of ur code, it should not give any error. But if u have any out.println() in ur code, i.e if ur writing something to the response body and then redirecting will not work. So please post the full code, tht will make the problem more clear.


bye.
 
Vijayendra V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kalai Selvan:
Hi,
Looking at the two lines of ur code, it should not give any error. But if u have any out.println() in ur code, i.e if ur writing something to the response body and then redirecting will not work. So please post the full code, tht will make the problem more clear.


bye.


Precisely. If, after you have set the content type for your response object and have already attempted to write something out to the client, and then, you try to use the sendRedirect( ) method, it will not work. Its better if you could please post your full code so that we can take a look at what you are trying to do.

 
arnold yan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly what the problem was. Thanks a lot!!!

Arnold
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic