Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servletConfig and servletContext

 
anita dhar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is difference between servletContext and servletConfig where we are using servletconfig and where we are using servletcontext
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are the main differences:

ServletContext is a single object that has information about the entire web application. It's associated with "application scope" and can be used to keep references to objects that any JSP or servlet can accesss.

The ServletConfig object has a narrower scope. There is one ServletConfig object for each servlet, and it's used to keep information about a specific servlet. One of the important uses of the ServletConfig object is to retrieve initialization parameters set for that servlet in the web.xml file.
 
Hanuma Deepak Muvvala
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some more differences
in web.xml
for Servlet Init Params that is init params get by ServletConfig the tag is
<init-param> which is child tag of servlet. But for ServletContext init Parameters the tag is <context-param> which is child tag of web-app.


You have getServletContext() method in ServletConfig. Many more....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic