tags:

views:

2067

answers:

3

Using tomcat, how do I get a request for http://www.mydomain.com to redirect to http://www.mydomain.com/somethingelse/index.jsp ? i haven't even managed to get an index.html to display from http://mydomain.com.

A: 

Name your webapp WAR “ROOT.war” or containing folder “ROOT”

flybywire
A: 

Take a look at UrlRewriteFilter which is essentially a java-based implementation of Apache's mod_rewrite.

You'll need to extract it into ROOT folder under your Tomcat's webapps folder; you can then configure redirects to any other context within its WEB-INF/urlrewrite.xml configuration file.

ChssPly76
A: 

You can do this: If your tomcat installation is default and you have not done any changes, then the default war will be ROOT.war. Thus whenever you will call http://yourdomain.com it will call index.jsp of your default WAR file. Do following changes in your /webapp/ROOT folder for redirecting request to http://www.mydomain.com/somethingelse/index.jsp.

  1. Open /webapp/ROOT/WEB-INF/web.xml and remove servlet mapping with path /index.jsp and save.

  2. Open your /webapp/ROOT/index.jsp and add this line:

    response.sendRedirect("http://www.mydomain.com/somethingelse/index.jsp");

That's it. I think this should work.

viralpatel