One Servlet Context object will be created by the container
for one webapplication. That means all servlets can have a
scope to acess that context object. for example, let us
assume there 5 servlets are there in u r web application,
if u want to share same data to all servlets then we can
share that data using servlet context, because every
servlet can have interaction with that application
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.
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
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.
servletcontext is an object which contains the information
regarding all the servlets that are used in web application.
when ever user first do the deployment of the web
application on the server the web container instantiate a
servlet context object.the information in the servlet
context object is also passed to init method.
Data saved in a ServletContext scope is shared by all
servlets and JSPs in the context. The data stored in the servlet
context is destroyed when the servlet context is destroyed.
//save and get an application-scoped value
value = getServletContext().getAttribute(“application-value”);
ServletContext is called web application there would be one servlet context for entire web applicationthe .servlet context is used to get the context parameters specified in web.xml and also get the information of servlet engineand also request dispatcher object.
as soon as the java web application is
deployed into web container ,the first
object that container create is
This object is only one per web application
Every web component of web application
share this unique object
i have problem in running of servlet.
i am using Tomcat server in my pc..
The problem is when i am click on strat it will display like
FAIL - Application at context path /first could not be started..
How i can slove the problem..