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 workflow of a servlet?
Which event is fired at the time of session creation and destroy?
how the HTML data stored in web server?
List out difference between a JavaBean from a Servlet?
How to commuincate between an applet and a servlet?
What are the different methods of session management in servlets?
What is the major difference between servlet and applet?
What are life cycle methods of a servlet?
What do you mean by interservlet communication?
What is the main purpose of java servlets?
What do you mean by cgi?
request parameter how to find whether a parameter exists in the request object?
What are the steps involved in placing a servlet within a package?
What is a servlet engine?
What is called a session?