What is ServletContext() and what is its use?

Answer Posted / telo

Data saved in a ServletContext scope is shared by all
servlets and JSPs in the context. The data stored in the servlet
context is destroyed when the servlet context is destroyed.
//save and get an application-scoped value
getServletContext().setAttribute(“application-value”,
“shopping-app”);
value = getServletContext().getAttribute(“application-value”);

Is This Answer Correct ?    28 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What’s the difference between genericservlet and httpservlet?

534


If a servlet is not properly initialized, what exception may be thrown?

631


What is generic servlet class?

606


Can you explain in detail 'javax.servlet' package?

551


How can you start a jta transaction from a servlet deployed on jboss?

677






Explain the working of service() method of a servlet.

508


What do you mean by default initialization in java servlet?

606


Which interface should be implemented by all servlets?

702


What is ServletConfig object?

612


When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

580


What is the difference between the servlets and cgi programs?

553


Is it possible to have a constructor inside the servlet?

554


Explain mvc pattern.

594


Explain the steps involved in placing a servlet within a package?

573


What is the purpose of inter-servlet communication?

597