Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filters

 
Frank Bueckert
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a slight problem with one of my filters. Basically, it holds a servletcontext variable, where it stores some values on startup. This is done to speed up the program, so that it's not constantly reading the same values in per person, or per request.

So, that means the values are static until Tomcat's restarted. My question is, is there any way to access that servletcontext variable? I'm trying to add in a way to force a re-load of values, so that we don't need to restart Tomcat all the time.

Thanks for the help!
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, there is. In any Action class, just use the getServlet() method provided by the Action superclass to get a reference to the ActionServlet. From there you gan get the Servlet context and reference it's attributes like this:

String myAttribute = (String)getServlet().getServletContext().getAttribute("myAttribute");
[ June 15, 2006: Message edited by: Merrill Higginson ]
 
Frank Bueckert
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect! Worked like a charm!

Thanks for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic