This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes ServletConfig vs ServletContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletConfig vs ServletContext" Watch "ServletConfig vs ServletContext" New topic
Author

ServletConfig vs ServletContext

Smitha Amresh
Greenhorn

Joined: Jun 13, 2005
Posts: 6
Hi folks,

What is the differance between ServletConfig and Servlet Context?
Which is same for all servlets(for the application.

Thanks in Advance.

Regards
Smitha Amresh Parika
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This question has been asked a few times here. Use the search tool with ServletConfig and ServletContext as keywords and you should be able to find
those conversations.

In the mean time, the best source of information for a question like this is the API documentation:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletConfig.html
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Sharad Agarwal
Ranch Hand

Joined: Sep 11, 2002
Posts: 167
Originally posted by Smitha Amresh:
Which is same for all servlets(for the application.


ServletContext


Alco-Haul: We move spirits.
Demented Deliberations of a Dilettante
Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
Servlet Config as the name suggests, provides Servlet specific configuration information to a particular servlet. For Example :- the information that u specify in the web.xml file like this

<servlet>
<init-param>...

</init-param>
</servlet>

Each servlet will have its own servlet config object, which will be specific to that servlet.

ServletContext
--------------
It provides application view to all the servlets. There is one ServletContext per JVM for one application.
It also provides methods to access application wide parameters specified
in <context-param>....</context-param> tag in web.xml.

These will be accessible to all the servlets.

I hope it works for you...


SCJP2, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletConfig vs ServletContext
 
Similar Threads
Why Init() method
Where does ServletContect come in the hierarchy ?
passing ServletContext
servletconfig in real environmet
getServletContext() method?