tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Murtuza <>
Subject Re: Tomcat 301 redirect
Date Tue, 25 Aug 2009 18:26:27 GMT

I only want to re-link old uri to home page and any request which does not
exist to error page. I added 


to web.xml and used below code which I found after google but
request.getRequestURI() returns 404.jsp rather then the old-page.html, so it
did not redirect the request.

//get the requested URI
String requestedLocation = request.getRequestURI();
//variable to store new location, if it exists
String newLocation;
do a database lookup (or other means to match up the requested URI with
one you wish to redirect). 
if (requestedLocation.equals("/myApp/old-page.html"))
  /*add some code in here to set the newLocation variable to a valid page*/
  newLocation = "http://localhost:8080/myApp/";
  //send HTTP 301 status code to browser
  //send user to new location
  response.setHeader("Location", newLocation);

View this message in context:
Sent from the Tomcat - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message