Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

JSP : Page Redirecting

Share this post!
 Vote this!

Page redirection is generally used when a document moves to a new location and we need to send the client to this new location or may be because of load balancing, or for simple randomization.
The simplest way of redirecting a request to another page is using method sendRedirect() of response object. Following is the signature of this method:
public void response.sendRedirect(String location)
throws IOException 
This method sends back the response to the browser along with the status code and new page location. You can also use setStatus() and setHeader() methods together to achieve the same redirection:
....
String site = "http://www.newpage.com" ;
response.setStatus(response.SC_MOVED_TEMPORARILY);
response.setHeader("Location", site); 
.... more...

0 comments:

Post a Comment