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 main purpose of java servlets?
Explain jsessionid?
What are the types of protocols supported by httpservlet ?
Is dispatcher servlet a singleton?
how to link html file to sevlet file.one name is textbox,c&c++ is cheakbox,bc&mca is radio button and one submit buttonis ok why in this programme use in servelt file
What are the uses of servlet
How do you invoke a Servlet? What is the difference between doPost method and doGet method?
How httpservlet is different from the genericservlet?
Is servlet thread safe?
What do you mean by session tracking?
What’s the difference between forward() and sendredirect() methods?
Explain the jar and war files in servlet?
How to create war file?
When a servlet accepts a call from a client, it receives two objects. What are they?
How to get the current httpsession object?