I created a class which implemnts ServletContextListener interface. In this class i override 'contextInitialized(ServletContextEvent sce)' abstract method which instantiated an object Of SomeClass . Now i want this object to be accessible to only one Servlet .. Is it possible to this using ServletContext , if yes , then How ?? OR any other way ?
You can use the ServletContext (accessible from ServletContextEvent) to store any objects using the setAttribute method. Those are accessible by all servlets, though. Generally I wouldn't consider that a problem - if other servlets are not supposed to use that object, then, well, they shouldn't use it. Or do you have reason to mistrust what other servlets are doing?