File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat 5.5.9 Redirect /index.jsp to / Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat 5.5.9 Redirect /index.jsp to /" Watch "Tomcat 5.5.9 Redirect /index.jsp to /" New topic
Author

Tomcat 5.5.9 Redirect /index.jsp to /

Justin Krettabull
Greenhorn

Joined: Sep 08, 2004
Posts: 26
Using Tomcat 5.5.9

I have a client requirement to redirect all requests to '/index.jsp' to '/'

In index.jsp, I added: response.sendRedirect("http://www.sitename.com/");

Since the welcome-file points to index.jsp, this becomes impossible because of an infinite loop.

So, I changed the welcome-file entry to 'main.jsp' and copied all of the 'content' from index.jsp into main.jsp. In index.jsp, I put the redirect to "http://www.sitename.com/".

Theoretically, all requests coming for /index.jsp should redirect to / and the default Tomcat servlet should include the contents of 'main.jsp'. There are no redirects in main.jsp, just content.

This should work, however it isn't. I have an infinite loop of redirects occuring. I changed the welcome-file in /conf/web.xml and the apps WEB-INF/web.xml. I also didn't forget to restart tomcat.

PS, I also tried using .htaccess, that doesn't work because Tomcat is serving the page and not Apache.

Any thoughts on this ridiculous (but very important to me) matter?

Why is Tomcat not using the welcome-file that points to main.jsp?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Are you using Apache HTTPD with a connector?
If so, could it be that httpd is serving up index.jsp when you redirect to www.sitename.com from Tomcat?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Justin Krettabull
Greenhorn

Joined: Sep 08, 2004
Posts: 26
We are using Apache mod_jk connector.

We have an Apache mapping for *.jsp to automatically forward to Tomcat.
Justin Krettabull
Greenhorn

Joined: Sep 08, 2004
Posts: 26
This issue is resolved.

My welcome-file in web.xml was being overridden by Apache's welcome-file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat 5.5.9 Redirect /index.jsp to /