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 is session?

819


How can you run a servlet program?

801


What are the steps that are involved in using the httpservlet class?

843


Can servlet have a constructor ?

805


How can the session in servlet be destroyed?

887


What are its drawbacks of cgi?

787


Why is a constructor needed in a servlet even if we use the init method?

823


What are the two important api's in for servlets?

808


What do you mean by session tracking and also explain its techniques?

690


What are the types of servlets? Explain

926


Is it good idea to create servlet constructor?

998


What is the advantage of Servlets when compared with other server side technologies?

2083


request parameter how to find whether a parameter exists in the request object?

785


How do cookies work in servlets?

804


Explain load on start-up and its importance?

843