String attributeName = "myAttribute"; Object attributeValue = servletContext.getAttribute(attributeName);
String attributeName = "myAttribute"; Object attributeValue = new Object(); servletContext.setAttribute(attributeName, attributeValue);In this example, we are setting the value of an attribute named "myAttribute" in the ServletContext to a new Object. Package library: javax.servlet