Here "javaranch" is the servlet class in hello directory. How does the container recognizes that javaranch is a servlet name and then checks the web.xml for the servlet class? There can be other html pages or jsps in hello directory.
So, does it check in the order of html page, jsps and then servlets or is there some thing else which I am missing?
But if the url is http://localhost:8080/hello/javaranch how does the container know that the request is for a servlet. There is nothing in the url that suggests the container to look into the web.xml file to find the mapping.
When a J2EE web container receives any request, it first checks it's list of servlet mappings from web.xml. Only if the request is not found in that list does it assume it's a file and display the file. If it is found, it calls the servlet.
In high volume sites, quite often there is a layer of one or more web servers that receive the initial request and then forward the request to the app servers. In this case, there is some type of plugin to the web server that tells it which requests to respond to and which to pass on to the application server. In this case, the data in web.xml is passed on to the web server in some manner (e.g. put in a config file and copied to the web server).