wood burning stoves 2.0*
The moose likes Struts and the fly likes Filters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Filters" Watch "Filters" New topic
Author

Filters

Frank Bueckert
Greenhorn

Joined: Mar 23, 2006
Posts: 8
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

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
Frank Bueckert
Greenhorn

Joined: Mar 23, 2006
Posts: 8
Perfect! Worked like a charm!

Thanks for your help.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Filters