• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Annotations

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 15484
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic