In my web.xml file I have this
<!-- WELCOME FILE LIST -->
<welcome-file-list>
<welcome-file>/index</welcome-file>
</welcome-file-list>
Which maps to this
<!-- SERVLET FOR THE HOME PAGE -->
<servlet>
<servlet-name>HomePageServlet</servlet-name>
<servlet-class>com.gmustudent.HomePageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HomePageServlet</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
When I put this in the address bar I get my home page site and the servlet grabs all of my content as requested.
http://localhost:8086/gmustudent/index
However, this gives me a 404
http://localhost:8086/gmustudent/
Why isn't my welcome file list grabbing that welcome file servlet when index is not explicitly stated?
The welcome files mechanism allows you to specify a list of files that the web container will use for appending to a request for a URL (called a valid partial request) that is not mapped to a web component.
Java web applications use a deployment descriptor file to determine how URLs map to servlets, which URLs require authentication, and other information. This file is named web. xml , and resides in the app's WAR under the WEB-INF/ directory.
The deployment descriptor is a file named web. xml . It resides in the app's WAR under the WEB-INF/ directory.
The load-on-startup element of web-app loads the servlet at the time of deployment or server start if value is positive. It is also known as pre initialization of servlet. You can pass positive and negative value for the servlet.
http://localhost:8086/gmustudent/
gmustudent is the context root of your webapplication. index is the resource
you wanna access.
you configure welcome file like below, remove the prepending / :
<welcome-file>Index</welcome-file>
</welcome-file-list>
to access
http://localhost:8086/gmustudent/
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