Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Context and Servlet Config

 
Pandian Raman
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the functionality of both Servlet Context and Servlet Config and when both will get initilized and destroyed?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17626
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman,

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

Regards,
Pandian R
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Already answered in the ServletsFaq. Please check the FAQ before posting.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic