篇一:web实验报告
一, 相关技术
为实现注册和登录功能,首先采用JSP和HTML分别设计regist和login页面,再采用servlet技术实现这两项功能。
为实现上传文件至服务器和下载自己上传的文件,也先JSP和HTML设计页面,再在页面中设计两按钮,点击时用调用JSP实现上传和调用servlet实现下载。
采用JSP和HTML设计result页面。是各种结果在result页面显示
二, 系统需求分析
为实现登录和注册。设计一个包,包中包含User类。User中有账号,密码,昵称三类属性。
设计登录页面,输入账号和密码实现登录。当输入信息正确时,显示成功,否则失败。
设计注册页面,输入账号,密码,昵称三属性实现注册。
设计上传和下载页面,点击相应按钮实现相应动作。
三, 系统设计和实验结果
1,显示结果页面核心代码
<% String message=(String)request.getAttribute("message"); %><%= message %>
2,注册相关代码
A,注册界面核心代码
<form method="post" action="Re">
<table > 账号: <input name="name" type="text" id="name"> 密码: <input name="pwd" type="password" id="pwd"> 昵称: <input name="call" type="text" id="call">
<input type="submit" value="注册"></table> </form>
B,实现注册的servlet核心代码
driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
Class.forName(driverName); String name = request.getParameter("name"); String pwd = request.getParameter("pwd"); String call = request.getParameter("call"); Connection con=null; String
dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=student";
String userName="sa";String userPwd="a693501"; con=DriverManager.getConnection(dbURL,userName,userPwd); PreparedStatement ps = null; String sql = "insert into admin (name,pwd,call)values(?,?,?)"; try{ ps = con.prepareStatement(sql); ps.setString(1,name); ps.setString(2, pwd); ps.setString(3, call); ps.executeUpdate();
C,结果截图
3,登录相关代码
A,登录界面核心代码
请登录<br>
<form method="post" action="login">
<table > 输入信息</p> 账号: <input name="name" type="text" id="name" >
密码:
<input name="pwd" type="password" id="pwd">
<input type="submit" value="登录"> </table> </form>
B,实现登录servlet核心代码
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
Class.forName(driverName);
Connection con=null;
String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=student";
String userName="sa";
String userPwd="a693501"; con=DriverManager.getConnection(dbURL,userName,userPwd);
PreparedStatement ps = null;
ResultSet rs = null;
User user=new User();
String sql = "select * from admin where name=? and pwd=?";
ps = con.prepareStatement(sql); ps.setString(1, name); ps.setString(2, pwd); rs = ps.executeQuery(); if (rs.next()) { user.setName(rs.getString("name")); user.setPwd(rs.getString("pwd")); user.setCall(rs.getString("call")); } else { } user = null;
if(null==user)
{ } else { }
C,结果截图 1,成功时
request.setAttribute("message", "login success"); request.getRequestDispatcher("/result.jsp").forward(request,response); request.setAttribute("message", "login fail"); request.getRequestDispatcher("/result.jsp").forward(request,response);
2,失败时
篇二:Web实验报告
实验一 HTML语言
一、实验目的
1.掌握常用的HTML语言标记;
2.利用文本编辑器建立HTML文档,制作简单网页。
二、实验要求
1.独立完成实验。
2.书写实验报告书。
三、实验内容
1.在文本编辑器“记事本”中输入如下的HTML代码程序,以文件名sy1.html保存,并在浏览器中运行。(请仔细阅读下列程序语句,理解每条语句的作用) 源程序清单如下:
<html>
<head>
<title>Example</title> //设置该HTML文本的标题
</head>
<body bgcolor="#00DDFF">//设置背景颜色
<h1><B><I><FONT COLOR="#FF00FF">//H1字体 加粗 倾斜 设置颜色
<MARQUEE BGCOLOR= "#FFFF00" direction=left behavior=alternate>welcome to you</MARQUEE>//设置走马灯 颜色 滚动方式
</FONT></I></B></h1>
<hr>
<h2 align=center><FONT COLOR="#0000FF">A simple HTML document</FONT></h2> <EM>Welcome to the world of HTML</EM>//H2字体 居中显示
<p>This is a simple HTML document.It is to give you an outline of how to write HTML file and how the<b> markup tags</b> work in the <I>HTML</I> file</p>
<p>Following is three chapters
<ul>
<li>This is the chapter one</li>//列表显示 标签一
<li><A HREF="#item">This is the chapter two</A></li>//列表显示 标签二
<li>This is the chapter three</li>//列表显示 标签三
</ul></p>
<hr>
<p><A NAME="item">Following is items of the chapter two</A> </p>
<table border=2 bgcolor=gray width="40%">
<tr>//设置表格 3行2列 设置背景颜色 边框大小
<th>item</th>
<th>content</th>
</tr>
<tr>
<td>item 1</td>
<td>font</td>
</tr>
<tr>
<td>item 2</td>
<td>table</td>
</tr>
<tr>
<td>item 3</td>
<td>form</td>
</tr>//设置每个单元格的内容
</table>
<hr><p>1<p>2<p>3<p>4<p>5<p>6<p>7<p>//打印1234567段
<B><I><FONT COLOR=BLUE SIZE=4>End of the example document </FONT></I></B> </p>
</body>
</html>
运行结果:
2.实现代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>表单范例</title>
<link rel = stylesheet type = "text/css" herf = pub.css>
</head>
<body>
<form action = "login.jsp" method = "post" onSubmit = "return on_submit()" name ="form1"> <table border = "0">
<td align ="center" valign = "middle" colspan = "2"><font size = "6"><u>请留下个人资料</u></font></td>
<br><br>
<tr> <td class = "word2">姓  名:</td><td><input type = "text" name = "name" value = "" class = "intput1"/></td></tr>
<tr> <td class = "word2">E-mail:</td><td><input type = "text" name = "name" value = "" class = "intput1"/></td></tr>
<tr> <td class = "word2">电  话:</td><td><input type = "text" name = "name" value = "" class = "intput1"/></td></tr>
<tr><td class = "word2">性  别:</td><td><input type = "radio" name = "gender" value = "female" checked>女性<input type = "radio" name = "gender" value = "male">男性</td></tr>
<tr><td class = "word2">年  龄:</td><td><select name = "age" > <option value = "20以下">20以下</option> <option value = "20-40">20-40岁</option></td></tr>
<tr> <td class = "word2">留言板: </td><td><textarea name = "brief" rows =5 cols = 30>请输入留言</textarea></td></tr>
<tr><td rowspan ="4" width = "40%" class = "word2" >您的爱好:</td><td width = "60%"> <input type = "checkbox" name = "in1" value = "sport" />体育 <br><input type = "checkbox" name = "in2" value = "read" />阅读 <br>
<input type = "checkbox" name = "in3" value = "music" />音乐<br><input type = "checkbox" name = "in4" value = "travel" />旅游</td></tr>
<tr> <td class = "my button "> <input type ="submit" value= "登陆" class =
"button1">   <input type ="reset" value= "重置" class = "button2"></tr> </table></form></body></html>
运行结果:
实验二 网页程序设计-JavaScript
一、实验目的
1.掌握JavaScript技术,基本掌握JavaScript的开发技巧;
2.利用文本编辑器建立JavaScript脚本语言进行简单编程。
二、实验要求:
1.根据以下实验内容书写实验准备报告。
2.独立完成实验。
三、实验内容
1.显示一个动态的时钟
在文本编辑器“记事本”中输入如下代码程序,请仔细阅读下列程序语句,理解每条语句的作用。源程序清单如下:
<html>
<head>
<script language="javascript">//设置编写语言
var timer = null//定义一个时间变量 置为空
function stop(){ //定义停止函数
clearTimeout(timer)}
function start(){//定义开始函数
var time = new Date()//创建新对象
var hours =time.getHours()
var minutes =time.getMinutes()
minutes=((minutes<10)?"0":”“)+minutes
var seconds=time.getSeconds()
seconds=((seconds<10)?"0":”“)+seconds
var clock =hours+":"+minutes+":"+seconds
document.forms[0].display.value=clock//设置时间显示方式与计算过程timer=setTimeout("start()",1000)}//显示时间
</script>
</head>
<body onLoad="start()" onUnload="stop()"> //运行时间函数
<form>
现在是北京时间:<input type="text" name="display" size="20">//添加一个文本框 </form>
</body>
</html>
分析上述代码的作用,然后用浏览器运行文件,验证自己的判断是否正确.
2.事件驱动和事件处理
在文本编辑器“记事本”中输入如下代码程序,请仔细阅读下列程序语句,理解每条语句的作用。源程序清单如下:
<html>
<head>
<script language="javascript">
function myfunction(){
alert("HELLO")
} //设置一个函数,功能是弹出一个显示HELLO的对话框
</script>
</head>
<body>
<form>
<input type="button" onClick="myfunction()" value="Call function">//添加一个按钮 </form>
<p>By pressing the button, a function will be called. The function will alert a message.</p>//添加一个段落
</body>
</html>
3.JavaScript表单校验
编写程序register.htm,做一个如下图所示的用户注册界面,要求对用户填写的部分进行合法性检验。
输入确认密码;
单选,多选按钮等,文本框。
读取出数据。 显示出数据(alert)
运行结果:
篇三:web程序设计实验报告
本科实验报告
课程名称: Web 程序设计基础
实验项目:
实验地点:
专业班级:软件工程学号:
学生姓名:
指导教师:
2012年4月
一、 实验目的
1. 掌握常用的HTML语言标记;
2. 利用文本编辑器建立HTML文档,制作简单网页。
二、 实验要求
1. 独立完成实验。
2. 书写实验报告书。
三、 实验内容
1. 在文本编辑器“记事本”中输入如下的HTML代码程序,以文件名sy1.html保存,并在浏览器中运行。
源程序清单如下:
<HTML>
<HEAD>
<TITLE>Example</TITLE>
</HEAD>
<BODY BGCOLOR="#00DDFF">
<H1>
<B>
<I>
<FONT COLOR="#FF00FF">
<MARQUEE BGCOLOR="#FFFF00" DIRECTION=LEFT BEHAVIOR=ALTERMATE>welcome to you!
</MARQUEE>
</FONT>
</I>
</B>
</H1>
<HR>
<H2 ALIGN=CENTER>
<FONT COLOR="#0000FF">A simple HTML document
</FONT>
</H2>
<EM>Welcome to the world of HTML!</EM>
<P>This is a simple HTML document. It is to give you an outline of how to write HTML file and how the <B>markup tags</B> work in the <I>HTML</I> file</P>
<P>Following in three chapters.
<UL TYPE=square>
<LI>This is the chapter one!</LI>
<LI><A HREF="#ITEM">This is the chapter two!</A></LI>
<LI>This is the chapter three!</LI>
</UL>
</P>
<HR>
<P>
<A NAME="ITEM">Following is item of the chapter two!
</A>
</P>
<TABLE BODER=2 BGCOLOR=GRAY WIDTH="40%">
<TR>
<TH>item</TH>
<TH>coment</TH>
</TR>
<TR>
<TD>item1</TD>
<TD>font</TD>
</TR>
<TR>
<TD>item2</TD>
<TD>table</TD>
</TR>
<TR>
<TD>item3</TD>
<TD>form</TD>
</TR>
</TABLE>
<hr>
<P>
1<P>2<P>3<P>4<P>5<P>6<P>7<P>
<B><I><FONT COLOR=BLUE SIZE=4>End of the example document</FONT></I></B></P>
</BODY>
</HTML>
运行结果:
2.编写一个能输入如图所示界面的HTML文件。
程序代码:
<HTML>
<HEAD>
<TITLE>表单范例</TITLE>
</HEAD>
<BODY background="E:\THREE\JSP\实验\实验一\4.jpg">
<H1 ALIGN=CENTER>请留下个人资料<HR SIZE=5 WIDTH=240 COLOR=MAROON></H1>
<FORM>
<P > 姓名:<INPUT TYPE="TEXT" NAME="姓名"><BR></P> <P >E-mail:<INPUT TYPE="TEXT" NAME="邮箱" SIZE=60><BR></P>
<P > 电话:<INPUT TYPE="TEXT" NAME="电话"><BR></P>
<P > 性别: <INPUT TYPE="RADIO" NAME="性别" CHECKED>女 <INPUT TYPE="RADIO" NAME="性别">男</P>
<P > 年龄:
<SELECT>
<option value=20 selected>20岁以下
<option value=30>20岁-30岁
<option value=40>30岁-40岁
<option value=50>40岁-50岁
<option value=60>50岁-60岁
</SELECT>
</P>
<P >留言版:<br><TEXTAREA NAME="留言板" ROWS=8 COLS=66 ></TEXTAREA></P> <P >
<INPUT TYPE="CHECKBOX" NAME="爱好">运动<BR>
您的爱好:<INPUT TYPE="CHECKBOX" NAME="爱好">阅读
<BR>
<INPUT TYPE="CHECKBOX" NAME="爱好">听音乐<BR>
<INPUT TYPE="CHECKBOX" NAME="爱好">旅游<BR></P>
<P ALIGN=CENTER>
<INPUT TYPE=SUBMIT VALUE=提交>
<INPUT TYPE=SUBMIT VALUE=全部重写>
</P>
</FORM>
</BODY>
</HTML>
运行结果:
《web实验报告》
由:免费论文网互联网用户整理提供,链接地址:
http://m.csmayi.cn/show/125363.html
转载请保留,谢谢!
- 上一篇:奥鹏教师教育网研修总结
- 下一篇:政协宣传标语