• Post Reply Bookmark Topic Watch Topic
  • New Topic

Annotations  RSS feed

 
LakshmiVenkat Sri
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Please clarify my below two questions

Questions1.
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.


Question2.
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?

Thanks & Regards,
Venkat
 
Stephan van Hulst
Saloon Keeper
Posts: 7385
130
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

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.
 
Rob Spoor
Sheriff
Posts: 20968
84
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!