This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes Servlets and the fly likes application scope in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "application scope in servlet" Watch "application scope in servlet" New topic
Author

application scope in servlet

kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
How will u set application scope in servlet?
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
There are at least two ways you can set an object in the Application scope. Both ways lead to you getting the ServletContext object.
1) This is usually done in the init(ServletConfig config) method.

2) If your Servlet extends HttpServlet. You can invoke the


But I think you get the idea.
Craig.
Afroz Ahmed
Ranch Hand

Joined: Jan 18, 2004
Posts: 64
Hello,
Exactly the same as Jack written.And also you can set the application scope paramater in web.xml at starting of your web application by
<webapps>
<context-param>
<param-name>author</param-name>
<param-value>abc</param-value>
</context-param>
</webapps>
and access these application scope params by the two ways specified by Jack in above reply.
Regards
Afroz Ahmed
SCJP(1.4)
SCWCD..on track


The value of an idea lies in the usage of it.
 
Don't get me started about those stupid light bulbs.
 
subject: application scope in servlet