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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "response.sendRedirect problem" Watch "response.sendRedirect problem" New topic
Author

response.sendRedirect problem

arnold yan
Ranch Hand

Joined: May 31, 2002
Posts: 40
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

Joined: Jul 07, 2004
Posts: 79
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

Joined: Jul 04, 2004
Posts: 195
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.



Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
arnold yan
Ranch Hand

Joined: May 31, 2002
Posts: 40
That's exactly what the problem was. Thanks a lot!!!

Arnold
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: response.sendRedirect problem
 
Similar Threads
Why is this url rewriting not working
Why is this code not working ?
And Spain goes left..
send bean from servlet to jsp
calling a servlets