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 cookie? Why is cookie used?
What are the steps involved in placing a servlet within a package?
Can we override servlet service method?
What's the use of servletcontext?
What methodology can be followed to store more number of objects in a remote server?
What are the various ways of session supervision in servlets?
why we should override only no-agrs init() method.
When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?
What is servlet invoker?
Explain the role of dispatcherservlet and contextloaderlistener.
Explain the steps involved in placing a servlet within a package?
Tell the new features added in servletrequest interface i.e. Servlet 2.4
Write a command to get actual path of a servlet to the server?
Is servlet a controller?
How many servlet objects are created?