Redirect All page from one domain to another domain in tomcat Views : 2211
Tagged in : JSP-Java
0 1
Send mail
If you want to move all the pages in a particular folder to other domain
example to

Then to the following changes in your code
Step 1:
changes your web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<display-name>Forum Moving </display-name>
<servlet-name>redirect.jsp </servlet-name>
<jsp-file>/redirect.jsp </jsp-file>
<servlet-name>redirect.jsp </servlet-name>

Here I'm redirecting all the request in that webapplication to "redirect.jsp"

Setp 2:
Create redirect.jsp file. Through this file we have to redirect the pages to the new domain

String file = request.getRequestURI();
if (request.getQueryString() != null) {
file += '?' + request.getQueryString();
response.setHeader( "Location", ""+file );
response.setHeader( "Connection", "close" );

By Vinoth, On - 2009-10-27

    Login to add Comments .