Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat 5.5.9 Redirect /index.jsp to /

 
Justin Krettabull
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Justin Krettabull
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using Apache mod_jk connector.

We have an Apache mapping for *.jsp to automatically forward to Tomcat.
 
Justin Krettabull
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This issue is resolved.

My welcome-file in web.xml was being overridden by Apache's welcome-file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic