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
Which method of the httpservletrequest object is used?
What is api in servlet?
What is the directory structure of a war file?
How do you create a cookie using servlet?
What is the use of welcome-file-list?
What does the term localization refer to?
How is an application exception handling is done using a servlet?
What are different Authentication options available in Servlets.
Can you refresh servlet in client and server-side automatically?
What is http servlet? Explain with the help of an example.
What is load-on-startup in servlet?
What is the advantage of Servlets when compared with other server side technologies?
Where do you define dispatcherservlet?
Why servlet is used as controller ? Not JSP? I want complete explation?
Tell us something about servletcontext interface.