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

Explain in brief the directory structure of a web application?

566


What do you mean by url pattern in servlet?

621


What is a servlet context?

596


How native code can be used in a servlet?

3518


Tell us something about servletconfig interface.

578






What are different methods of session management in servlets?

772


What is meant by servlet? What are the parameters of the service method?

568


How do you communicate in between Applets and Servlets?

591


What do you mean by singlethreadmodel interface?

578


How httpservlet is different from the genericservlet?

560


What is generic servlet class?

596


How to make sure a servlet is loaded at the application startup?

549


What are the benefits of using servlet over cgi?

572


How servlet is created?

540


What is life cycle of Servlet?

605