• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Config and Servlet Context

 
Abhay Choubey
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

What is the use of servlet config and servlet context.
can any one help me.

thanks in advance
Abhay
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should have searched before posting: See This

Or please atleast be specific to what you want to ask.
 
Abhay Choubey
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have searched and got some point related to it.

My question is very simple i want to know why we use of it.

Abhay
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose that you have a servlet which can not service client requests unless you initialize it properly. ServletConfig is used for initializing a particular servlet, and holds the servlet specific init-parameters configurable through deployment descriptor. When the servlet instance is created container creates a corresponding ServletConfig object and calls the servlet's init(ServletConfig) method passing the servletConfig object. Which can be used for obtaining the init-parameter information from it.
ServletConfig is one per servlet.

Similarly if you want that all of your servlets have access to same initialization parameters then instead of copying them in all the servletConfigs you can use ServletContext's init-parameters (context-param). ServletContext is one per web-application. so all the servlets share one ServletContext.

Besides it, ServletContext can also be used for sharing Objects by setting attributes.
 
Abhay Choubey
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it

Thanks a lot
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic