How to call the resource that is available in another web server by using response.sendRedirect()?

Showing Answers 1 - 6 of 6 Answers

akantilal

  • Jun 12th, 2007
 

You can very much use the same response.sendRedirect method to redirect to a resource on another web server. You can provide the absolute URL along with the protocol name like response.sendRedirect(http://www.google.com);

  Was this answer useful?  Yes

amit_9b

  • May 2nd, 2009
 

Using this method is pretty straight-forward. BUt there is a simple catch:
No data should be committed to the servlet output stream before the redirection occurs.
In case data has been committed and then redirection is forced, an IllegalStateException is thrown.

EXAMPLE >>

...
...
/* your java code  */

// first of all empty buffer to ensure
// that no data is committed to the client
response.reset();

// Now redirect to target URL
response.sendRedirect("http://www.google.com");

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions