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
What are the different ways we can maintain state between requests?
What are the types of servlets? Explain
What is the purpose of requestdispatcher interface?
What is the procedure for initializing a servlet?
What is the directory structure of web application?
Why HttpServlet class is declared abstract?
What is the purpose of dispatcherservlet properties?
What are different Authentication options available in Servlets.
What do you mean by deployment descriptor?
What is the inter-servlet communication?
What is the web server used for running the Servlets?
What is cgi?
What do you mean by cgi in servlet?
Difference between GET and POST?
Describe the phases of servlet lifecycle?