Index.jsp file opens even if <welcome-file-list> is not defined
I wrote a simple dynamic web project in Eclipse Luna. On the web.xml page, I removed the welcome-file-list tag by default.
<?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 goes to index.jsp in the "WEB-INF" section even after I removed the welcome-file-list tag from web.xml . How does it link to index.jsp , although welcome-file-list not in web.xml ?
If you use an instance of Tomcat 7 and do not specify a list of welcome files, the container (tomcat) considers it by default, i.e. 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 changing anything in the default tomcat, because your web application should not depend on the container that runs it. Instead, you should define your own list of welcome files in your own web.xml. Hope this helps!
If the welcome list is not presented, the container will try to download the following files in the order shown:
- index.html
- index.htm
- index.jsp
Update: regarding the cat
If web.xml is not specified in the application, the default web.xml ($ CATALINA_HOME / conf / web.xml) Tomcat is provided to the application. This deployment descriptor has the following lines:
<!-- --> <!-- If you define welcome files in your own application 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> This is why index.jsp is displayed by default
Update source: fooobar.com/questions/798544 / ...
The default file will call index.jsp if you change the file name. Then it will not be found index.jsp , and you can get the expected result.