The only difference i found is the class that sets the attribute on the servletcontext extends ServletContextListener.
the class that access and reads the context extends HttpServlet and shows the content upon an http request. the class that gets the null pointer, also extends HttpServlet but it's instantiated from another class and a method is called from there. there's no http request on this class. i've also declared this class as a servlet in the web.xml of my app. On Jan 31, 2011, at 4:40 PM, Caldarale, Charles R wrote: >> From: alexis [mailto:alz...@gmail.com] >> Subject: Re: custom class as resource > >> LiveInfo li = (LiveInfo) sc.getAttribute("live"); > >> why im getting a null pointer on the sc.getAttribute line? > > Because you never created an attribute named "live" in the ServletContext. > > - Chuck > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY > MATERIAL and is thus for use only by the intended recipient. If you received > this in error, please contact the sender and delete the e-mail and its > attachments from all computers. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org