How to change default index.jsp page in java web project

When we create a Java web project with maven or a dynamic web application in Java using advanced IDE like Eclipse, Netbeans, etc. By default, it creates a file “index.jsp” and when we run the project “index.jsp” is launched as the welcome page of the project. can by change the default index.jps?

Yes, we can keep any .jsp or HTML file a the welcome page of our project. there is another default file called web.xml in the project. web.xml is used for the configuration of the project.

Change default index.jsp page in java web project

in web.xml we can update the welcome file using <welcome-file> </welcome-file> tag. <welcome-file>View/jsp/home.jsp</welcome-file>  in <welcome-file> tag we just need to pass the path of the file that should be the welcome page of the project.

<web-app>
  <display-name>Archetype Created Web Application</display-name>
   <welcome-file-list>  
   <welcome-file>View/jsp/home.jsp</welcome-file>     
  </welcome-file-list>   
</web-app>

Can we use multiple welcome files in web.xml

Yes, We can define multiple welcome file but each file will be in <welcome-file> </welcome-file> tag and all <welcome-file> </welcome-file>  will be come under the <welcome-file-list> </welcome-file-list> list tag.

In case of multiple files, controller will run as per priority top to bottom files in the list.