Welcome File Configuration in Servlet

Advertisements

Servlet Load on Startup Servlet First Program

Welcome File Configuration in Servlet

A welcome file is the file that is invoked automatically by the server, if you don't specify any file name. Welcome file is a default starting page of the website.

The welcome-file-list element of web-app, is used to define a list of welcome files. Its sub element is welcome-file that is used to define the welcome file.

By default server looks for the welcome file in following order:

  1. index.html
  2. index.htm
  3. index.jsp

Note: If welcome file is not configure and index.html or index.jsp does not exits in an application then container sends http status 404 message to the browser.

If you have specified welcome-file in web.xml, and all the files index.html, index.htm and index.jsp exists, priority goes to welcome-file.

If welcome-file-list entry doesn't exist in web.xml file, priority goes to index.html file then index.htm and at last index.jsp file.

Let's see the web.xml file that defines the welcome files.

web.xml

Example

<web-app>  
 ....  
    <welcome-file-list>  
   <welcome-file>home.html</welcome-file>  
   <welcome-file>home.jsp</welcome-file>  
  </welcome-file-list>  
</web-app>  

Now, home.html and default.html will be the welcome files.

If you have the welcome file, you can directory invoke the project as given below:

Example

http://localhost:8888/myproject/ 

As you can see, we have not specified any file name after the project.


Servlet Load on Startup Servlet First Program

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements