Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServleContext In Beans

 
Vikas Aggarwal
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have create an Object and Placed in the context using "getServletContext().setAttribute("x", xyz)" in a servlet. Now I want to access the same from the servlet context in a bean/class. How it can be done?
Thanks
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way to do it is to pass the servlet context object to your class. You could pass it in in the constructor and hold onto it for the lifetime of the instance, or pass it in through another method.
Kyle
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic