1

I want to understand how the web-container maps incoming requests to a particular web-application (and a servlet afterwards).

To begin with, I believe a web-container must be able to listen for incoming Http requests (else how will the client reach to web-application at all). This assumption I believe holds correct. If this is not correct, then how does request will ever reach to web-container?

Now, assume I wrote a web-application (based on plain servlets i.e., not using any other framework like Spring MVC), create the .war file, say firstwebapp.war; and deployed it in Apache Tomcat, with context root /firstapp

Now, the client makes request to the deployed web-application as:

http://servername:port/firstapp

How does the web-container handle this request? Where is this mapping of /firstapp to the web-application deployed as firstwebapp.war?

Does web-container first "sees" the incoming request URL before passing on the control to respective web-application? And based on what criteria is it able to map to proper .war?

CuriousMind
  • 8,301
  • 22
  • 65
  • 134

1 Answers1

1

Yes, the server will see /firstapp first and know where to rout it. After that it depends on your war, e.g., your web.xml.

mvd
  • 2,596
  • 2
  • 33
  • 47
  • But where is this mapping defined? I know at the time of deployment, in tomcat we specify /contex_root to a particular .war? Is this information stored somewhere in tomcat? – CuriousMind Apr 01 '16 at 19:31