What is ServletContext() and what is its use?
Answer Posted / shyam
if u want to use any data which is common for all use and
common to all servlet ,that data can be specified as context
parameters in the web.xml as follows.
<context-param>
<param-name>city</param-name>
<param-value>bangalore</param-value>
</context-param>
web container collects data from web.xml and stores that in
servlet context objects as context parameters.
As a developer,you can collect that data form context object
as follows.
String ci=context.getIntParameters("city").
All the servlets will have only one servlet context object
and can be shared with all servlets running in the container.
i.e: one web application will have one servletcontext object.
| Is This Answer Correct ? | 53 Yes | 3 No |
Post New Answer View All Answers
What is the use of send redirect () method?
How native code can be used in a servlet?
What are the advantages of Servlet over CGI?
What is ServletConfig object?
Is that servlet is pure java object or not?
Why do we have servlet filters?
What do you mean by a filter and how does it work?
What is a server side include (ssi)
Explain load on start-up and its importance?
Describe servlet?
What is the difference between servlet and jsp?
How the JSP file will be executed on the Server side?
Is dispatcher servlet a singleton?
How to create war file?
What is the difference between the http servlet and generic servlet?