Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between servlet config and servlet
context.

Answer Posted / mansi

• Signature: public interface ServletConfig
ServletConfig is implemented by the servlet container to
initialize a single servlet using init(). That is, you can
pass initialization parameters to the servlet using the
web.xml deployment descriptor. For understanding, this is
similar to a constructor in a java class.
Example code:
<servlet>
<servlet-name>ServletConfigTest</servlet-name>
<servlet-class>com.javapapers.ServletConfigTest</servlet-class>
<init-param>
<param-name>topic</param-name>
<param-value>Difference between ServletConfig and
ServletContext</param-value>
</init-param>
</servlet>
• Signature: public interface ServletContext
ServletContext is implemented by the servlet container for
all servlet to communicate with its servlet container, for
example, to get the MIME type of a file, to get dispatch
requests, or to write to a log file. That is to get detail
about its execution environment. It is applicable only
within a single Java Virtual Machine. If a web applicationa
is distributed between multiple JVM this will not work. For
understanding, this is like a application global variable
mechanism for a single web application deployed in only one JVM.
The ServletContext object is contained within the
ServletConfig object. That is, the ServletContext can be
accessed using the ServletConfig object within a servlet.
You can specify param-value pairs for ServletContext object
in <context-param> tags in web.xml file.
Example code:
<context-param>
<param-name>globalVariable</param-name>
<param-value>javapapers.com</param-value>
</context-param>

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the need of session tracking in web application?

975


Why are http servlets used in programming?

961


What is the difference between Servlets and Applets?

966


What are the two important api's in for servlets?

1013


What exactly is a servlet?

943


What is a servlet?

1073


What is the use of httpservletrequestwrapper?

1039


Should I override the service() method?

1041


What is the difference between genericservlet and httpservlet

1019


What are session variable in servlets?

979


Differentiate between get and post?

1102


Why do we need servlet filter?

1004


request parameter how to find whether a parameter exists in the request object?

954


Which exception is thrown if the servlet is not initialized properly?

975


What is the need of servlet filters?

938