jsp程序设计实验报告

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
if (name == null){ throw new RuntimeException("没有指定name 属
算法 描述 或实 验步 骤
性。"); } %> Hello, <%= name %> </body> </html> 【步骤2】下面的errorHandler.jsp是错误处理页面。 <%@ page contentType="text/html; charset=gb2312" %> <%@ page isErrorPage="true" %> <html> <body> 请求不能被处理:<%=exception.getMessage()%><br> 请重试!
</body> </html> (二)运行下面的JSP页面square.jsp <html><body>
<table border=’1’ cellspacing=’0’ cellpadding=’5’> <tr><th>number</th><th>squared</th></tr> <% for ( int i=0; i<10; i++ ) { %> <tr><td><%= i %></td><td><%= (i * i) %></td></tr> <% } %> </table> </body></html>
number squared
0 0 1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64 9 81
本次试验让我熟悉了tomcat路径,应用程序路径, 和学会了简单JSP 总 结 的应用,并掌握了JSP的声明和理解了page指令的一些属
性。
附录
2.熟练掌握JSP的声明 3. 理解page指令的下面的属性
实验 环境
机房
(一) errorPage属性和isErrorPage属性的使用。 (二)运行下面的JSP页面square.jsp (三)改写上述页面,使其运行后产生下列页面。
实验 内容
(一) errorPage属性和isErrorPage属性的使用。 【步骤1】下面的hello.jsp页面执行时将抛出一个异常, 它指定了错误处理页面为errorHandler.jsp。
<%@ page contentType="text/html;charset=gb2312" %> <%@ page errorPage="errorHandler.jsp" %> <html> <body> <% String name = request.getParameter("name");
<td><%= (i * i) %></td> <% } %> </tr> </table> </body></html>
(一) 【步骤1】用下面的URL访问hello.jsp页面,就会产生
下面结果: http://localhost:8080/bookstore/hello.jsp 如
图1.1
图1.1 errorHandler.jsp页面的运行结果 【步骤2】使用下面URL访问 hello.jsp页面,将产生 下面正常的页面:
(三)改写上述页面,使其运行后产生下列页面。 <html><body> <table border=’1’ cellspacing=’0’ cellpadding=’5’>
<tr> <% for ( int i=0; i<10; i++ Βιβλιοθήκη Baidu { %>
<td><%= i %></td> <% } %> </tr> <tr> <% for ( int i=0; i<10; i++ ){ %>
http://localhost:8080/bookstore/hello.jsp? name=Mary 如图1.2
调试 过程 及实 验结 果
图1.2 hello.jsp页面的运行结果
(二)
用http://localhost:8080/bookstore/hello.jsp?name=Mary访 问,结果为
哈尔滨理工大学软件工程系
实验报告
课程名称:JSP程序设计教程 班 级:软件 学 号: 姓 名:
教务处印制
姓名
实验 地点
指导 教师
实验 日期
2014.9.11
熟悉tomcat路 实 验 径,应用程序 名 称 路径,简
单JSP应用
实验 成绩
1. 熟悉tomcat路径,应用程序路径,JDK版本
实验 目的 及要 求
相关文档
最新文档