• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

response.sendRedirect problem

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's exactly what the problem was. Thanks a lot!!!

Arnold
 
Yup, yup, yup. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic