Guys,
I have the doubt in the code below that I got from David Bridgewater's book,
10 // "out" is the response's PrintWriter
11 out.write("<H2>Context (Application) Scope</H2>");
12 ServletContext context = getServletContext();
13 String myAttributeName = "com.osborne.conductor";
14 context.setAttribute(myAttributeName, "Andre Previn");
15
16 enum = context.getAttributeNames();
17 while (enum.hasMoreElements()) {
18 attrName = (String) enum.nextElement();
19 attrValue = context.getAttribute(attrName);
20 out.write("<BR />Attribute name: <B>" + attrName + "</B>, value: <B>"
21 + attrValue + "</B>");
22 }
23 String conductor = (String) context.getAttribute(myAttributeName);
24 out.write("<BR /> Just used getAttribute() to obtain "
25 + myAttributeName + " whose value is " + conductor);
26
27 context.removeAttribute(myAttributeName);
28 context.setAttribute(myAttributeName, null);
29
30 out.write("<BR />Value of attribute " + myAttributeName + " is now "
31 + context.getAttribute(myAttributeName));
I want to know what like 18 and 19 does??
I have the doubt in the code below that I got from David Bridgewater's book,
10 // "out" is the response's PrintWriter
11 out.write("<H2>Context (Application) Scope</H2>");
12 ServletContext context = getServletContext();
13 String myAttributeName = "com.osborne.conductor";
14 context.setAttribute(myAttributeName, "Andre Previn");
15
16 enum = context.getAttributeNames();
17 while (enum.hasMoreElements()) {
18 attrName = (String) enum.nextElement();
19 attrValue = context.getAttribute(attrName);
20 out.write("<BR />Attribute name: <B>" + attrName + "</B>, value: <B>"
21 + attrValue + "</B>");
22 }
23 String conductor = (String) context.getAttribute(myAttributeName);
24 out.write("<BR /> Just used getAttribute() to obtain "
25 + myAttributeName + " whose value is " + conductor);
26
27 context.removeAttribute(myAttributeName);
28 context.setAttribute(myAttributeName, null);
29
30 out.write("<BR />Value of attribute " + myAttributeName + " is now "
31 + context.getAttribute(myAttributeName));
I want to know what like 18 and 19 does??