I have one query regrading servlet annotations that is how web container will know what are the servlets are deployed in one war file.
With out Annotations: If we configure the servlets in web.xml file then the web server will check the specific url mapping in web.xml(deployment descriptor) file.
With Annotations:: if we used the annotations to define servlet java classes. How the server will map the servlets when request come from the browser.
Will the server check each servlet .class file for annotation url mapping.
How the internal mechanism will work in the server.
How the annotation mechanism will work in case of spring controller? how it will handle by dispatcher servlet? will it read all the mappings and maintain any metadata map?
I can't say for certain, but my guess is that when the web application container loads your application, it scans all classes in certain packages for annotations that it's interested in. It then updates the mappings it keeps in memory the same way it would if it had gotten the information out of the web.xml. I think you still use the web.xml to specify the packages it should scan for annotations.
When a request comes in, it just uses the mappings it keeps in memory. This is regardless of whether the mappings were built from web.xml or annotations.
Some (most?) containers don't even need any entries in your web.xml, they will simply scan the entire application for any classes annotated with any of the supported annotations, in the same way that JEE containers can automatically detect all EJBs.