When you need to move a document to a new location, you need to use JSP redirection.
The simplest way to redirect is to use the sendRedirect() method of the response object. The signature of this method is as follows:
public void response.sendRedirect(String location)throws IOException
This method sends the status code and new page position back to the browser as a response. You can also use the setStatus() and setHeader() methods to get the same effect:
....String site = "http://www.downcodes.com" ;response.setStatus(response.SC_MOVED_TEMPORARILY);response.setHeader("Location", site); ....
This example shows how JSP does page redirection:
<%@ page import="java.io.*,java.util.*" %><html><head><title>Page Redirection</title></head><body><center><h1>Page Redirection</h1></center><% // Redirect to the new address String site = new String("http://www.downcodes.com"); response.setStatus(response.SC_MOVED_TEMPORARILY); response.setHeader("Location", site); %></body></html>
Save the above code in the PageRedirecting.jsp file and then visit http://localhost:8080/PageRedirect.jsp and it will take you to //www.downcodes.com/.