Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ServleContext In Beans  RSS feed

 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!