aspose file tools*
The moose likes Struts and the fly likes servletConfig and servletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "servletConfig and servletContext" Watch "servletConfig and servletContext" New topic
Author

servletConfig and servletContext

anita dhar
Ranch Hand

Joined: Jul 14, 2007
Posts: 69
what is difference between servletContext and servletConfig where we are using servletconfig and where we are using servletcontext
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Hanuma Deepak Muvvala
Ranch Hand

Joined: Nov 20, 2005
Posts: 158
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....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servletConfig and servletContext
 
Similar Threads
Getting servlet context in many ways
Why Init() method
Servlet Config and ServletContext
Where does ServletContect come in the hierarchy ?
servletcontext and servletconfig