On Jan 20, 2004, at 8:19 AM, Niall Gallagher wrote:
I am relatively new to Velocity and I have been trying to write a shared Context for a group of Servlets. However, I see in the Javadoc documentation that the VelocityContext object is not thread safe, I have also examined the hierarchy of super classes and find that it pretty much comes down to the InternalContextBase.icachePut and InternalContextBase.icacheGet methods.
Exactly, so if I did somthing like servletContext.setAttribute("sharedContext", mySharedContext) and multiple independant servlets required access to the context to render a template, then there would be a problem with the AST caching and also setting and getting from the context...at least this is what I have understood of the AbstractContext.
Perhaps I didn't catch the point ... but ... what if you synchronize the methods accessing your context object?
That might work, but that would be solving a slightly different problem, right? aren't you trying to share some of your application data between servlets?
geir
Yes, but you could wrap that context in each use :
VelocityContext vc = new VelocityContext(servletContext.getAttribute("sharedContext")) // or whatever
and that would probably be ok
geir
Niall
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Geir Magnusson Jr 203-247-1713(m) [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
