AttributeCheck.jsp
To work this example save this file in the jsp directory of ayour jakarta-tomcat-4.0.1. Open up the
web browser and try your URL localhost:8080/examples/jsp/CallAttributeCheck.jsp This sample shows
how the first object associated with the attribute "query" is not stored, Although the last is. Using
attributes is a powerful technique for sharing infromation, like logon data, between JSP pages.
AttributeCheck.jsp < %@page import="java.util.*"%> < html> < head> < title >Attribute Check< /title> < /head> < body> < h1>Attribute Names and Values< /h1> < hr/> < p> < % string name; string value; for( Enmumeration names = request.getAttributesNames(); names.hasMoreElements() ;) { name = (String)names.nextElement() ; value = (String)request.getAttribute(name) ; % > < /p> < font size="4">< %= name % > < /font>: < %= value % > < % } % > < /body> < /html>
In order to demonstrate the use of the request attributes, you need to first set them and
then call the attribute-listing JSP page. Using CallAttributeCheck.jsp first sets several
attributes and illustrating that only the most recent binding is retained in the case of
the "query" where two are listed.
|