Is there any differance b/w getting servlet context from
servlet config and session? if yes then what is that?

Answer Posted / sandhya

YES,There is some difference,when we deploy the web
application the web container will create the Context
object and when we load the servlet class then container
will create config object,so for each web application web
container will create one servlet context obj and for each
servlet web container will create servlet config object.

Generally we use this objects to avoid the hardcoding,we
declare this variables in deployment descriptor,we declare
context parameters under web-app tag so that all servlets
can use this parameter values ,and config parameters under
servlet tag so that only specific servlet can use this
parameter values,in simple way context object is like
global object and config obj is like local obj.

Is This Answer Correct ?    8 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is an application exception handling is done using a servlet?

751


What is the difference between the getrequestdispatcher(string path) method of javax.servlet.servletrequest interface and javax.servlet.servletcontext interface?

766


What’s the use of the servlet wrapper classes??

841


Describe the phases of servlet lifecycle?

811


How we can create war file in servlet?

846


What are the various ways of session supervision in servlets?

747


What is servlet collaboration?

869


How do you design microservices?

818


How do you deal property files in servlet?

785


Which event is fired at the time of project deployment and undeployment?

1047


Why is servlet used?

896


What is servlet interface?

938


What are the type of protocols used in httpservlet?

796


Why is init() method is used in servlets?

730


What is the disadvantage of cookies?

771