I've written a simple dynamic web project in Eclipse Luna. In web.xml page I've removed the default welcome-file-list
tag.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>indextest</display-name>
</web-app>
But the url http://localhost:8080/indextest/ still directs to index.jsp
under 'WEB-INF' even after I've removed the tag welcome-file-list
from web.xml
. How it directs to index.jsp
page though welcome-file-list
is absent in web.xml
?
If you are using a Tomcat 7 instance, and are not specifying the welcome-file-list, the container (tomcat) is looking into his default, that is in /conf/web.xml in your tomcat instance.
These are the lines:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
I suggest not to change anything in the tomcat default, because your web application should not be dependent on the container that runs it. Instead, you should define your own welcome-file-list in your own web.xml. Hope this helps!
If there is no welcome list provided then the container will try to load the below files in the order defined:
Update: regarding tomcat
If no web.xml is provided in the application, the default web.xml($CATALINA_HOME/conf/web.xml) of Tomcat is supplied to the application. This deployment descriptor has the following lines:
<!-- -->
<!-- If you define welcome files in your own application's web.xml -->
<!-- deployment descriptor, that list *replaces* the list configured -->
<!-- here, so be sure to include any of the default values that you wish -->
<!-- to use within your application. -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
That is why the index.jsp is shown by default
Source for update: https://stackoverflow.com/a/17247947/1129313
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With