Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

application scope in servlet

 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How will u set application scope in servlet?
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic