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

Answer Posted / rajendra singh bisht

You can get reference to ServletContext through ServletConfig. HttpSession does not provide a reference to ServletContext object.

To get a ServletContext object use

getServletConfig().getServletContext();

or you can call directly getServletContext() bcoz GenericServlet class implements ServletConfig interface also.

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of an http request?

656


Which method of the httpservletrequest object is used?

663


When servlet is loaded?

678


Explain the methods of request dispatcher in servlet?

600


List some life cycle methods of a servlet.

668






Explain the difference between get and post method in servlet?

706


What is cgi and what are its drawbacks?

627


What are the exceptions thrown by servlets? Why?

710


How do you find out what client machine is making a request to your servlet

617


how many jsp scripting elements are there and what are those?

649


Write all the phases defined in servlet life cycle?

660


How we can get ip address of client in servlet?

630


Explain the jar and war files in servlet?

642


What are the life-cycle methods for a servlet?

628


Can we use threads in Servlets?

735