we use servlet context to share common parameters between all the servlets in our application;we store them in web.xml(contextparam).we retrive them through getInitParameter;but servletcontext interface also has setAttribute;getattribute methods;where we have to use them and how thaknz
but servletcontext interface also has setAttribute;getattribute methods;where we have to use them and how
You can use those methods to share data (which might be the result of a calculation based on the user's answer on a form) between all the servlets in your application. However, the data isn't thread safe, so another request from another client can set those variables to something else before the servlets handling the first request have a chance to read them. [ October 14, 2006: Message edited by: sven studde ]
From what I believe, the parameters in the xml file are read only. The context parameters added and removed at runtime are read/write.
Be careful with the ServletContext. It is not necessarily workload managed across JVMs in a clustered environment, so not only is it not threadsafe, but contexts can also get out of sync. A centralized database is so much nicer to use in a workload managed environment.