• 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

Servlet Context and Servlet Config

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the functionality of both Servlet Context and Servlet Config and when both will get initilized and destroyed?
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pandian raman wrote:What is the functionality of both Servlet Context and Servlet Config and when both will get initilized and destroyed?



The same question has been asked about people.

The Servlet Context exists for the life of the webapp. The Servlet Config is the information taken from the web.xml file.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pandian raman wrote:What is the functionality of both Servlet Context and Servlet Config and when both will get initilized and destroyed?


initialization:
ServletContext-after application deployed into server
ServletConfig-after servlet initialized(in init method)
destruction:
ServletContext-after application undeployed
ServletConfig-after servlet unloaded
 
Pandian Raman
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim.

Thanks Seetharaman.

Seetharaman,

You mean the servlet config will initilized for each and every servlet request.

Regards,
Pandian R
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pandian raman wrote:
Seetharaman,
You mean the servlet config will initilized for each and every servlet request.


servlet get initialized in init method. and there is only one instance for a servlet regardless request.
container creates thread for every request and runs on a single servlet instance.
So, Only one time servlet config get initialized and it is used to get servlet specific values from web.xml also to get ServletContext object.

 
Pandian Raman
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seetharaman,

Cool man, i have absolutely got your point. I am clear now, thanks dude.

Regards,
Pandian R
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Already answered in the ServletsFaq. Please check the FAQ before posting.
 
Die Fledermaus does not fear such a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic