What is the difference between servlet config and servlet
context.

Answer Posted / srikanth

ServletConfig :-

-> one per servlet or one per JSP

-> this object is usefull to pass additional information to
servlet and to gather information about servlet. so this
object is called right hand object of servlet or JSP
program.

-> servlet container creates and distroyes this obj with
respact to our servlet obj creation and distraction.

-> Non java web resource programs of web applications
does't contain ServletConfig obj.

->ServletConfig obj means it is the ibj of class that
implements javax.servlet.ServletConfig interface. this
class name changes based on the web server or application
server we use.

->this obj is usefull to read intilization parameters of
servlet that are configared in the web.xml file.



ServletContext :-

-> one per web application.

->ServletContext obj and its data is visable and accessble
in the all the web resoure programs of web application. So
ServletContext obj is also called as global memory of the
web application.

->Servlet container creates this ServletContext obj during
the deployment of web application and distroys this obj
when web application is stoped or reloaded or undeployed.

->ServletContext obj is very usefull

a) to gather global inti parameters / context parameters
from web.xml file.

b) to know the details about underlaying server where
the web application is deployed.

c) to know the web resource programs of the web
application

->ServletContext obj means that is obj of a class which
inplements javax.servlet.ServletContext interface. this
implementation calss name will change base on the web
server or application server we are useing.

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the requirement of servlet config and servlet context implemented and how are they implemented?

532


What are the key methods that are involved in processing of http servlets?

614


Name the packages that work with servlet?

535


What is called Scriptlet?

551


The code in a finally clause will never fail to execute, right?

591






Which event is fired at the time of setting, getting or removing attribute from application scope?

598


What is the structure of the http response

662


What is meant by a web application

531


What are the phases of servlet life cycle?

597


What is the servlet?

610


How do we translate jsp?

562


Why do we have servlet listeners?

589


How do I use cookies to store session state on the client?

523


What is servlet and its types?

548


What is the difference between portlet and servlet?

506