Calling Servlet data variable from Java Class
===

I'm trying to access a variable from a Servlet, I'm trying to store it in the context using : 

    getServletContext().setAttribute("package", "name");

And then in this Servlet class I store a reference to this context in a public variable : 

    public static ServletContext c;
    c=getServletContext();

Then in my java class I try to access the data like this : 

    ServletContext a = DeviceInfo1.c; //DeviceInfo1 is the name of the servlet class
    String name = (String) a.getAttribute("org.deri.hcls.caregap2.client");

But I get a HTML error 500, can anyone see what I'm doing wrong? Am I passing or accessing the context incorrectly?