What is ServletContext() and what is its use?
Answer Posted / asif shahzad
1. ServletContext is a window by which a Servlet instance see its environment.
2. ServletContext defines some methods that a Servlet instance can use to communicate with Servlet Container. E.g. To dispatch request, Writing to a log file etc.
3. Servlet Container pass the ServletConfig object to the Servlet instance when calling init(ServletConfig config) method. ServletContext instance reference exist inside the ServletConfig object.
4. Each Web application has only one ServletContext instance. So its a singleton object. If an Servlet Container deploys multiple Apps, each App have its own ServletContext.
Is This Answer Correct ? | 98 Yes | 8 No |
Post New Answer View All Answers
Define the servlet mapping.
Explain load on start-up and its importance?
How do servlets work?
What is Client-Server Computing?
Explain mvc pattern.
Difference between doget and dopost?
What is servlet in simple terms?
What is context in servlet?
What is the inter-servlet communication?
What is the difference between forward () and sendredirect () functions in servlet? Explain
What do you mean by cgi and what are its drawbacks?
What is the use of welcome-file-list?
What are all the ways for session tracking?
What are the important functions of filters?
What is the use of request dispatcher interface?