| Author |
Servlet Context
|
Vikas Aggarwal
Ranch Hand
Joined: Jun 22, 2001
Posts: 140
|
|
I need to know the following: 1. Is a Servlet Context is something private to the servlet who has created it? 2. Is it possible to access an attribute from servlet context in a servlet which has been previuosly set by another servlet. 3. What's the life cycle for the Servlet Context attribute? Thanks
|
Vikas Aggarwal
Founder @
Leads and Deals Limited
www.LeadsAndDeals.com
|
 |
Syed Zackriya Hussainy
Ranch Hand
Joined: Jun 24, 2002
Posts: 30
|
|
|
good
|
 |
Syed Zackriya Hussainy
Ranch Hand
Joined: Jun 24, 2002
Posts: 30
|
|
|
good
|
 |
L Goundalkar
Ranch Hand
Joined: Jul 05, 2001
Posts: 395
|
|
1. Is a Servlet Context is something private to the servlet who has created it? Its not private. But the context provides the space for exchaging the data between web components. Its is the View of servet towards the application. 2. Is it possible to access an attribute from servlet context in a servlet which has been previuosly set by another servlet. Yes it is possible to change the attribute of another servlet using the servlet context object of the first one. 3. What's the life cycle for the Servlet Context attribute? I think it is same as Servlet. Cheers.
|
<b>L G Goundalkar</b><br /> <a href="mailto:lggoundalkar@yahoo.com" rel="nofollow">lggoundalkar@yahoo.com</a> <br />Sun Certified Programmer for Java 2 Platform.<br />Sun Certified Web Component Developer for J2EE.
|
 |
Anthony Villanueva
Ranch Hand
Joined: Mar 22, 2002
Posts: 1055
|
|
1. Is a Servlet Context is something private to the servlet who has created it?
There is only one ServletContext object per web application. All servlets and JSPs of that web application have access to the ServletContext object.
2. Is it possible to access an attribute from servlet context in a servlet which has been previuosly set by another servlet.
Yes. You can consider the ServletContext object as a repository of "global" data for your web applications. However, the set/getAttribute() methods are not synchronized, so be careful.
3. What's the life cycle for the Servlet Context attribute?
Unlike a servlet, which can have many instances, a ServletContext attribute remains bound to the ServletContext object as long as the ServletContext object itself exsts, unless it is explicitly unbound by removeAttribute().
|
 |
sandy gupta
Ranch Hand
Joined: Jan 30, 2001
Posts: 228
|
|
There are only 2 ways to remove attributes set in the servletContext: 1) as suggested above 2) by booting the server The servlet context object is the "handle to a servlet" and exists for the life time of the application with which the servlet is bound
|
Adios
|
 |
Anthony Villanueva
Ranch Hand
Joined: Mar 22, 2002
Posts: 1055
|
|
The servlet context object is the "handle to a servlet" and exists for the life time of the application with which the servlet is bound
You mean "handle to the web application", right?
|
 |
 |
|
|
subject: Servlet Context
|
|
|