I am developing a Java Web Application which consists of a lot of JSPs, JSs, Servelts, while business logic is handled in POJOs.
My need is to initiate a class inside my Servlet, and set is as a global variable, and use it throughout all the packages in my application.
Now, I have defined a few global variables using
request.getSession().setAttribute("<ATTR_NAME>", <MY_OBJECT>);
But what I am lacking here is I can use the value of this attribute only inside the Servlet, or in other words, places where I have access to HttpServletRequest.
I need a solution to define a global variable, and be able to use it in all my POJOs which contain my business logic, where I may not have access to HttpServletRequest. I also do not want to pass this global variable of mine from the Servlet to all these POJOs either through Constructors or method arguments.
I have gone through a few articles which spoke about ServletContext amongst other things, but I do not get a clear picture.
Any little help is highly appreceated.
Thanks, Sriram Sridharan