top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the Difference between Servlets Context and Servlet Config?

+1 vote
423 views
What is the Difference between Servlets Context and Servlet Config?
posted May 11, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Servlet Config

Servlet config object represent single servlet.

Its like local parameter associated with particular servlet.

It’s a name value pair defined inside the servlet section of web.xml file so it has servlet wide scope.

getServletConfig() method is used to get the config object.

for example shopping cart of a user is a specific to particular user so here we can use servlet config.

Servlet Context

It represent whole web application running on particular JVM and common for all the servlet.

Its like global parameter associated with whole application.

ServletContext has application wide scope so define outside of servlet tag in web.xml file.

getServletContext() method is used to get the context object.

To get the MIME type of a file or application session related information is stored using servlet context object.

answer May 11, 2016 by Karthick.c
...