Solution:
The files used to run the application are:
1. ParamId.jsp
2. ParamObj.jsp
<html>
<head></head>
<body>
<jsp:include page="ParamObj.jsp" >
<br>
<jsp:param name="param1" value="val1" />
<br>
<jsp:param name="param2" value="val2" />
<br>
<jsp:param name="param3" value="val3" />
</jsp:include>
<br>
<b>Calling page:<b>
<br>
Name1: <%= request.getParameter("param1") %>
<br>
Name2: <%= request.getParameter("param2") %>
<br>
Name3: <%= request.getParameter("param3") %>
<br>
</body>
</html>
Save the code as ParamId.jsp in the C:\Tomcat 5.5\Webapps\basic directory.
<html>
<body>
<h2>Called page: </h2>
<b>Names:</b>
<br>
Name1: <%= request.getParameter("param1") %>
<br>
Name2: <%= request.getParameter("param2") %>
<br>
Name3: <%= request.getParameter("param3") %>
<br>
</body>
</html>
Save the code as ParamObj.jsp in the C:\Tomcat 5.5\Webapps\basic directory. The http://localhost:8080/basic/ParamObj.jsp?param1= Alice¶m2=Bob¶m3=Cathy path is entered into the Web browser. This passes the three parameters Eric, Alice, and Bob to the ParamId.jsp page.
The output of the program is as shown in Figure 4.5.
0 nhận xét:
Post a Comment