Java Reference
In-Depth Information
L ISTING 15.4
Continued
out.println(“Could not get the Properties from the application!”);
}
else {
// The properties were found in the application, iterate over them
Enumeration enum = props.propertyNames();
while ( enum.hasMoreElements() ) {
String name = (String)enum.nextElement();
out.println(“<B>” + name + “:</b>”
+ props.getProperty(name) + “<br>”);
}
}
%>
</body>
</html>
As you can see, the GetFromApplication.jsp first checks the application object for a refer-
ence to the Properties . If it cannot find the object, it writes a message to the implicit out
object stating this. If it does find the Properties object, GetFromApplication.jsp iterates
over the object, printing out the name:value pairs.
Testing the JSPs
To test your JSPs, perform the following steps:
1.
Copy all the files into the < SERVER_ROOT >/djs/ directory.
2.
Open your browser to the following URL:
http:// localhost /djs/StoreInApplication.jsp
N OTE
When you open your browser during step 2, no output will be displayed in the
browser.
3.
Then, open your browser to the following URL:
http:// localhost /djs/GetFromApplication.jsp
When you open your browser in step 3, you should see a page similar to Figure 15.3.
Search WWH ::




Custom Search