Sunday, 20 March 2016

How do I override the default home page loaded by Tomcat ?


Inside $TOMCAT_HOME/conf/web.xml there is a section called <welcome-file-list>and it looks like this : 
<welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
The default servlet attempts to load the index.* files in the order listed.

You may easily override the index.jsp file by creating an index.html file at $TOMCAT_HOME/webapps/ROOT.
It's somewhat common for that file to contain a new static home page or a redirect to a servlet's main page.

A redirect would look like : 
<html>
  <head>
     <meta http-equiv="refresh"content="0;URL=http://mydomain.com/some/path/to/servlet/homepage /">
  </head>
  ....
</html>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.