Web实验报告Word文档下载推荐.docx
《Web实验报告Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《Web实验报告Word文档下载推荐.docx(22页珍藏版)》请在冰点文库上搜索。
源代码见实验结果
2.编写一个能输出如图所示界面的HTML文件。
三、主要仪器设备
笔记本电脑、AdobeDreamweaverCC2015
四、实验结果
1.
(1)源代码:
<
html>
head>
title>
Example<
/title>
/head>
bodybgcolor="
#00DDFF"
>
h1>
B>
I>
FONTCOLOR="
#FF00FF"
MARQUEEBGCOLOR="
#FFFF00"
direction=leftbehavior=alternate>
welcometoyou<
/MARQUEE>
/FONT>
/I>
/B>
/h1>
hr>
h2align=center>
#0000FF"
AsimpleHTMLdocument<
/h2>
EM>
WelcometotheworldofHTML<
/EM>
p>
ThisisasimpleHTMLdocument.ItistogiveyouanoutlineofhowtowriteHTMLfileandhowthe<
b>
markuptags<
/b>
workinthe<
HTML<
file<
/p>
Followingisthreechapters
ul>
li>
Thisisthechapterone<
/li>
AHREF="
#item"
Thisisthechaptertwo<
/A>
Thisisthechapterthree<
/ul>
ANAME="
item"
Followingisitemsofthechaptertwo<
<
tableborder=2bgcolor=graywidth="
40%"
tr>
th>
item<
/th>
content<
/tr>
td>
item1<
/td>
font<
item2<
table<
item3<
form<
/table>
1<
2<
3<
4<
5<
6<
7<
FONTCOLOR=BLUESIZE=4>
Endoftheexampledocument<
/body>
/html>
(2)运行结果:
①文本编辑器“记事本”中输入HTML代码程序,以文件名sy1.html保存
②在浏览器中运行
2.
(1)源程序
!
doctypehtml>
metacharset="
utf-8"
个人资料填写<
body>
h2align="
center"
strong>
u>
请留下个人资料<
/u>
/strong>
tablealign="
form>
tdalign="
right"
姓名:
inputtype="
text"
name="
user"
>
E-mail:
email"
size="
50"
电话:
phone"
30"
性别:
radio"
sex"
女&
nbsp;
&
男<
年龄:
selectname="
age"
1"
optionvalue="
20"
selected>
20岁以下<
/option>
20岁-30岁<
40"
30岁-40岁<
40岁-50岁<
60"
50岁-60岁<
/select>
留言板:
textareacols="
rows="
5"
/textarea>
您的爱好:
checkbox"
hobby"
value="
运动"
运动<
br>
阅读"
阅读<
听音乐"
听音乐<
旅游"
旅游
tralign="
tdcolspan="
2"
<
submit"
提交"
reset"
全部重写"
/form>
②运行结果:
蔡潇钰
2015.11.16
网页程序设计JavaScript
1.掌握JavaScript技术,基本掌握JavaScript的开发技巧;
2.利用文本编辑器建立JavaScript脚本语言进行简单编程。
1.显示一个动态的时钟
在文本编辑器“记事本”中输入如下代码程序,请仔细阅读下列程序语句,理解每条语句的作用。
分析代码作用,然后用浏览器运行文件,验证自己的判断是否正确。
2.事件驱动和事件处理
3.JavaScript表单校验
编写程序register.htm,做一个如下图所示的用户注册界面,要求对用户填写的部分进行合法性检验。
1.
(1)源代码
scriptlanguage="
javascript"
vartimer=null
functionstop(){clearTimeout(timer)}
functionstart()
{
vartime=newDate()
varhours=time.getHours()
varminutes=time.getMinutes()
varseconds=time.getSeconds()
minutes=((minutes<
10)?
"
0"
:
)+minutes
seconds=((seconds<
)+seconds
varclock=hours+"
+minutes+"
+seconds
document.forms[0].display.value=clock
timer=setTimeout("
start()"
1000)
}
/script>
bodyonLoad="
onUnload="
stop()"
现在是北京时间:
inputtype=type="
display"
size=20>
(2)实验结果
2.
(1)源代码
functionmyfunction(){
alert("
HELLO"
)
}
button"
onClick="
myfunction()"
Callfunction"
Bypressingthebutton,afunctionwillbecalled.Thefunctionwillalertamessage.<
3.
(1)源代码
请输入密码<
functionon_submit()
{
if(form1.username.value=="
{
alert("
用户名不能为空,请输入用户名!
);
form1.username.focus();
returnfalse;
}
if(form1.userpassword.value=="
alert("
用户密码不能为空,请输入密码!
form1.userpassword.focus();
formmethod="
POST"
action="
regist.jsp"
form1"
onsubmit="
returnon_submit()"
&
用户登陆<
请输入用户名:
username"
21"
请输入密码:
password"
userpassword"
B1"
B2"
2015.11.17
Request与Response对象的应用
1.掌握JSP的Request与Response隐式对象的用法,基本掌握JSP的开发技巧。
2.在JDK和Eclipse环境下,完成下列实验。
编写程序实现一个单选小测试。
在test.jsp页面显示问题,并将答案提交至answer.jsp进行判断,如果回答正确,则将页面转至yes.jsp;
否则,转至no.jsp。
(1)源代码
test.jsp
%@pagelanguage="
java"
import="
java.util.*"
pageEncoding="
%>
北京欢迎您!
h2>
北京奥运会开幕日期是:
formaction="
answer.jsp"
method="
post"
date"
checkedvalue="
6"
8月6日
8"
8月8日
9"
8月9日
10"
8月10日<
提交答案"
answer.jsp
%>
%
Stringmydate;
mydate=request.getParameter("
if(mydate.equals("
))
response.sendRedirect("
yes.jsp"
elseresponse.sendRedirect("
no.jsp"
yes.jsp
h1align="
恭喜您答对了!
no.jsp
很抱歉,您答错了!
①选择“8月6日”并点击“提交答案”
②选择“8月8日”并点击“提交答案”
Application对象Session对象
一.实验目的和要求
1.掌握JSP的Application对象Session对象对象的用法,基本掌握JSP的开发技巧。
二.实验内容
1.请仔细阅读下列程序语句,理解每条语句的作用。
源程序清单如下:
%@pagecontentType="
text/html;
charset=gb2312"
网页计数器<
%if(application.getAttribute("
counter"
)==null)
application.setAttribute("
"
else{
Stringstrnum=null;
strnum=application.getAttribute("
).toString();
inticount=0;
icount=Integer.valueOf(strnum).intValue();
icount++;
application.setAttribute("
Integer.toString(icount));
}%>
您是第<
%=application.getAttribute("
)%>
位访问者!
2.上述计数器当进行刷新时也会自动加1,试编写程序count.jsp,实现防刷新文本计数器。
3.编写程序register.htm和register.jsp,做一个用户注册的界面,要求对用户填写的部分进行合法性检验,然后提交到register.jsp进行注册检验,若用户名为user开头的,就提示“该用户名已被注册”,若用户名为admin,就提示“欢迎您,管理员”,否则,就显示“注册成功”。
三、主要仪器设备
JDK和Eclipse环境
四、实验结果
2.<
contentType="
charset=UTF-8pageEncoding="
UTF-8"
metahttp-equiv="
Content-Type"
content="
charset=UTF-8"
%
if(application.getAttribute("
if(session.isNew())
{Stringstrnum=null;
}
}%>
个访问者!
3.
r.jsp:
Inserttitlehere<
register.jsp"
用户登录:
Register.jsp:
%Stringstr2=newString(request.getParameter("
).getBytes("
ISO-8859-1"
),"
if(str2.substring(0,4).equals("
))
{out.println("
该用户名已被注册"
out.print("
5秒后自动跳转"
response.setHeader("
refresh"
5;
url=register.jsp"
}
elseif(str2.equals