J2EE实验讲义计算机科学与技术专业 黑龙江大学.doc

上传人:文库蛋蛋多 文档编号:2386791 上传时间:2023-02-17 格式:DOC 页数:17 大小:1.15MB
返回 下载 相关 举报
J2EE实验讲义计算机科学与技术专业 黑龙江大学.doc_第1页
第1页 / 共17页
J2EE实验讲义计算机科学与技术专业 黑龙江大学.doc_第2页
第2页 / 共17页
J2EE实验讲义计算机科学与技术专业 黑龙江大学.doc_第3页
第3页 / 共17页
J2EE实验讲义计算机科学与技术专业 黑龙江大学.doc_第4页
第4页 / 共17页
J2EE实验讲义计算机科学与技术专业 黑龙江大学.doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

《J2EE实验讲义计算机科学与技术专业 黑龙江大学.doc》由会员分享,可在线阅读,更多相关《J2EE实验讲义计算机科学与技术专业 黑龙江大学.doc(17页珍藏版)》请在三一办公上搜索。

1、黑龙江大学“J2EE”实验讲义黑龙江大学计算机科学技术学院2009年6月目 录实验1 WEB开发环境(1学时)11.实验内容、目的、类型12.预习内容13.实验要求14.实验提示1实验2 HTML与JavaScript(1学时)21.实验内容、目的、类型22.预习内容23实验要求2实验3 JSP基础(2学时)31.实验内容、目的、类型32.预习内容33.实验要求34.实验提示3实验4 JSP内置对象1(2学时)51.实验内容、目的、类型52.预习内容53.实验要求54.实验提示5实验5 JSP内置对象2(2学时)71.实验内容、目的、类型72.预习内容73.实验要求74.实验提示8实验6 JD

2、BC应用(4学时)91.实验内容、目的、类型92.预习内容93.实验要求94.实验提示11实验7 Servlet与MVC(6学时)121.实验内容、目的、类型122.预习内容123.实验要求124.实验提示12实验1 WEB开发环境(1学时)1.实验内容、目的、类型内容:安装并测试Tomcat服务器。目的:熟悉运行环境的安装和使用。类型:验证型2.预习内容WEB服务器的种类、安装、测试。3.实验要求(1) 通过解压方式安装Tomcat服务器,安装目录为C: apache-tomcat-6.0.18,端口号为9000。启动该服务器并访问其默认主页http:/127.0.0.1:9000。(2)

3、通过Tomcat的主页访问其“JSP Examples”、“Servlet Examples”、“Tomcat Documentation”、“Tomcat Manager”和“Status”等链接内容。(3) 查看安装目录内的Webapps、Work子目录内容。(4) 将上面的Tomcat停止,启动系统中已经安装的Tomcat,并重新测试其运行效果。(5) 通过另一台机器访问所安装的Tomcat服务器。(6) 将课堂实例部署到Tomcat服务器中,并查看网页HTML源代码。4.实验提示(1) 启动Tomcat服务器之前,应保证环境变量JAVA_HOME值为JDK安装目录(如c:program

4、 filesjavajdk1.6.0)(2) tomcat的端口修改:在confserver.xml文件中修改(默认:8080)。实验2 HTML与JavaScript(1学时)1.实验内容、目的、类型内容:设计一个用户注册页面,并实现简单的JavaScript验证。目的:了解和掌握基本的HTML标签和JavaScript语法。类型:验证型2.预习内容HTML、JavaScript相关内容。3实验要求(1) 编写实现用户注册的HTML页面,表单的action属性为任意。(2) 将上述页面部署到服务器上,并通过访问该页面查看页面效果。(3) 在页面内增加简单的JavaScript验证代码,以验证

5、用户名称为空、用户名称或密码长度不足等问题。实验3 JSP基础(2学时)1.实验内容、目的、类型内容:(1) 编写一个能够显示九九乘法口诀表的JSP网页。(2) 编写一个网站计数器页面。目的:掌握JSP语法和JSP页面的部署和运行过程。类型:验证型2.预习内容JSP语法,JSP页面的部署。3.实验要求(1) 口诀内容显示到表格内,否则显示格式不易控制。(2) 在index.jsp中调用Java类的相应函数,获取最新的网站计数器值并以图形形式显示出来。计数器值存储在文本文件中。显示效果如下图所示:4.实验提示实现计数器网页时需要注意以下几个地方:(1) 利用Java类读取文本文件中的当前计数值后

6、,应立即更新文本文件内容,为下一个访问者做好计数准备。(2) 文本文件存储在tomcatbin文件夹内,否则打开文件失败。(3) 图片计数器可由连续输出的若干个标签组成,图片文件名与计数器值的每位数字对应,图片文件名应区分大小写。实验4 JSP内置对象1(2学时)1.实验内容、目的、类型内容:编写一个猜数游戏程序。目的:掌握JSP的request、out、session对象。类型:验证型2.预习内容JSP内置对象。3.实验要求在index.jsp中输入一个0-100之间的整数,并把输入数据提交给猜数页面guess.jsp,index.jsp和guess.jsp的界面如下图所示。 在guess.

7、jsp中判断所输入数据与游戏程序中生成的随机数之间的大小关系。如果小,则显示“小了”,并通过“再试一次”链接返回index.jsp;如果大,则显示“大了”,并通过“再试一次”链接返回index.jsp;如果相等,显示“猜对了”,重新设置随机数,并通过“重新开始新游戏”链接返回index.jsp开始新一轮游戏。在游戏过程中仅当猜对时才能重新开始游戏,不能每猜一次更换一次数据。index.jsp:guess.jsp:返回到index.jsp4.实验提示在index.jsp中只需要输入猜测的整数,而在guess.jsp中判断大小关系。在guess.jsp中还需要生成原始的随机数,并把它保存到sess

8、ion中:% int num=Integer.parseInt(request.getParameter(num);/表单中输入的数if (session.getAttribute(randNum)=null) session.setAttribute(Integer)(Math.random()*100); int randNum= session.getAttribute(randNum);if( numrandNum) out.println(小了.);out.println(再来一次);else if(.)/略else/略%实验5 JSP内置对象2(2学时)1.实验内容、目的、类型内容

9、:实现一个具有登录表单信息自动填充功能的网页。目的:掌握JSP的request、response对象。类型:验证型2.预习内容JSP内置对象。3.实验要求(1) 编写主页index.jsp,可参考如下页面:(2) 在登录验证页面login.jsp中只需简单判断用户名为abc、密码为123即可。关键应判断复选框选中与否状态,并将对应值保存到cookie中,最后通过简单的链接返回到index.jsp。4.实验提示(1) index.jsp不仅要显示表单,还应读取cookie。如能读到用户名称或密码,将读到的值自动填充到表单内。(2) 判断复选框是否被选中可以用如下代码: String rememb

10、erMe1=request.getParameter(rememberme1); if(rememberMe1 != null & rememberMe1.equals(on) Cookie myCookie=new Cookie(loginname,userName); /以下从略 实验6 JDBC应用(4学时)1.实验内容、目的、类型内容:利用JDBC实现好友录程序。目的:掌握JDBC。类型:设计型2.预习内容JSP、JDBC。3.实验要求(1) 应具有注册、登录功能,并可以对当前用户好友信息进行全部或模糊查询(添加新记录,删除或修改原有记录功能留到下一实验完成)。(2) 注册页面为Reg

11、ister.jsp,登录页面为login.jsp,登录之前不能访问与注册、登录无关的页面。登录和注册功能应由独立的Java类实现。(3) 编写主页index.jsp,内容包括查询所有好友信息和按姓名模糊查询好友信息两个链接。(4) 编写实现“查询所有好友信息”功能的JSP页面allfriend.jsp,并利用Java类访问登录用户的好友信息。(5) 编写实现“按姓名模糊查询”功能的页面queryByName.jsp。模糊查询功能只需实现按姓名查询,如输入“李”,可查询处所有姓名中带有“李”字的好友信息。(6) 数据库访问功能应由独立的Java类实现。(7) 可参考如下页面:4.实验提示(1)

12、MySQL数据库中至少创建用户表user和好友信息表friends。他们的逻辑结构和关系如下图所示:(2) 各组件之间关系如下图所示:实验7 Servlet与MVC(6学时)1.实验内容、目的、类型内容:将好友录程序改造为Model 2 MVC结构。目的:掌握Servlet和MVC框架。类型:综合型2.预习内容JSP、Servlet、JDBC。3.实验要求将实验6改造为符合Model 2的MVC结构程序,核心控制器由Servlet实现。4.实验提示(1) index.jsp通过控制器调用Java类,并返回到allFiend.jsp:(2) 注册和登录页面通过控制器调用Java类,并返回到ind

13、ex.jsp:(3) 访问Servlet时可传送不同的requestId,如查询所有好友信息时requestId为1,模糊查询时requestId为2,登录时requestId为3,注册时requestId为4。例如,index.jsp的第一个链接可定义为。Winger Tuivasa-Sheck, who scored two tries in the Kiwis 20-18 semi-final win over England, has been passed fit after a lower-leg injury, while Slater has been named at ful

14、l-back but is still recovering from a knee injury aggravated against USA.Both sides boast 100% records heading into the encounter but Australia have not conceded a try since Josh Charnleys effort in their first pool match against England on the opening day.Aussie winger Jarryd Hayne is the competiti

15、ons top try scorer with nine, closely followed by Tuivasa-Sheck with eight.But it is recently named Rugby League International Federation player of the year Sonny Bill Williams who has attracted the most interest in the tournament so far.The Kiwi - with a tournament high 17 offloads - has the chance

16、 of becoming the first player to win the World Cup in both rugby league and rugby union after triumphing with the All Blacks in 2011.Id give every award back in a heartbeat just to get across the line this weekend, said Williams.The (lack of) air up there Watch mCayman Islands-based Webb, the head o

17、f Fifas anti-racism taskforce, is in London for the Football Associations 150th anniversary celebrations and will attend Citys Premier League match at Chelsea on Sunday.I am going to be at the match tomorrow and I have asked to meet Yaya Toure, he told BBC Sport.For me its about how he felt and I wo

18、uld like to speak to him first to find out what his experience was.Uefa hasopened disciplinary proceedings against CSKAfor the racist behaviour of their fans duringCitys 2-1 win.Michel Platini, president of European footballs governing body, has also ordered an immediate investigation into the refer

19、ees actions.CSKA said they were surprised and disappointed by Toures complaint. In a statement the Russian side added: We found no racist insults from fans of CSKA. Baumgartner the disappointing news: Mission aborted.The supersonic descent could happen as early as Sunda.The weather plays an importan

20、t role in this mission. Starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where our day-to-day weather l

21、ives. It will climb higher than the tip of Mount Everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. As he crosses the boundary layer (called the tropopause),e can expect a lot of turbulen

22、ce.The balloon will slowly drift to the edge of space at 120,000 feet ( Then, I would assume, he will slowly step out onto something resembling an Olympic diving platform.They blew it in 2008 when they got caught cold in the final and they will not make the same mistake against the Kiwis in Manchest

23、er.Five years ago they cruised through to the final and so far history has repeated itself here - the last try they conceded was scored by Englands Josh Charnley in the opening game of the tournament.That could be classed as a weakness, a team under-cooked - but I have been impressed by the Kangaroo

24、s focus in their games since then.They have been concentrating on the sort of stuff that wins you tough, even contests - strong defence, especially on their own goal-line, completing sets and a good kick-chase. Theyve been great at all the unglamorous stuff that often goes unnoticed in the stands bu

25、t not by your team-mates.It is as though their entire tournament has been preparation for the final.In Johnathan Thurston, Cooper Cronk, Cameron Smith and either Billy Slater or Greg Inglis at full-back they have a spine that is unmatched in rugby league. They have played in so many high-pressure ga

26、mes - a priceless asset going into Saturday.The Kiwis are a lot less experienced but winning a dramatic match like their semi-final against England will do wonders for their confidence.They defeated Australia in the Four Nations final in 2010 and the last World Cup, and know they can rise to the big occasion.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号