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
Why do we have servlet wrapper classes?
What is java servlet?
What mechanisms are used by a Servlet Container to maintain session information?
What's the advantages using servlets than using cgi?
Explain the difference between a web server and a web container?
What is Servlets and explain the advantages of Servlet life cycle?
What are the uses of servlets?
What is war file?
What do you mean by servlet context?
Who is responsible for writing a constructor?
How is a servlet implemented in code?
Difference between get and post in java servlets?
What is the use of httpservletresponsewrapper?
What is the difference between forward () and sendredirect () functions in servlet? Explain
What are the different methods involved in generic servlet?