Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Tomcat find the HOME PAGE of my Web App?

I am just getting started to learn about Web Apps and deploying them to Tomcat. So I started with a sample web app project - made up of struts, hibernate, etc., etc.

The ANT build was successful. Also, was able to deploy the web app through an xml under Catalina/host. I am able to open the web site with no issues.

This is the structure of my web app

-exploded       -WEB-INF            -classes            -lib            -web.xml      -index.jsp      -welcome.html 

My question is

How does Tomcat know which is the first page / starting page / home page that it is supposed to open? Which file is this specified in?

like image 733
Van de Graff Avatar asked Oct 20 '10 08:10

Van de Graff


People also ask

How do I get Tomcat welcome page?

ROOT folder has config files for 'Welcome' page for tomcat. You can copy it from the other tar file into ../webapps folder and you'll be good. Symlinking ROOT to your webapp's folder does a great job and adds a little bit more flexibility.

How do I find the default Tomcat page?

The easiest would be to have the Tomcat home page (TOMCAT_HOME/webapps/ROOT/index. jsp) perform a redirect to your start page. Or, if you have just a single web app, you can move that to the ROOT web app. Thanks a lot for the quick reply.


1 Answers

In any web application, there will be a web.xml in the WEB-INF/ folder.

If you dont have one in your web app, as it seems to be the case in your folder structure, the default Tomcat web.xml is under TOMCAT_HOME/conf/web.xml

Either way, the relevant lines of the web.xml are

<welcome-file-list>         <welcome-file>index.html</welcome-file>         <welcome-file>index.htm</welcome-file>         <welcome-file>index.jsp</welcome-file>     </welcome-file-list> 

so any file matching this pattern when found will be shown as the home page.

In Tomcat, a web.xml setting within your web app will override the default, if present.

Further Reading

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

like image 104
JoseK Avatar answered Oct 04 '22 19:10

JoseK