When trying to set Context attributes like so:
void init()
{
String testing = new String();
testing = "This is a test";
getServletContext().setAttribute("test", testing);
}
In one servlet, and getting the attribute like so:
String testing = (String) getServletContext().getAttribute("test")
In a second servlet, testing
is null
.
Does this mean my servlets are in separate contexts? If so, how could I access the context attributes of the first servlet? Please provide a reference for this as I am relatively new to java/servlets.
I am using Netbeans with Glassfish 3.
EDIT: They are both in the same webapp and are both defined in the same WEB-INF/web.xml