JSP程序设计技术报告
信管121
杨晋宇
学号:201210901147
2015/6/16
引言
这学期我们学习了JSP程序设计技术这门课,这门课我们是理论与理论与实践相结合。我们知道上机实验是学习程序设计语言必不可少的实践环节,特别是因特网编程技术,其涉及的内容广泛,抽象,还繁琐,更需要实际的编程来真正的掌握它。每次实验之前我们几乎都是在讲了理论知识的情况下才到实验室真正的自己操作。这样不仅避免了只学理论知识的枯燥无味,还是我们学习的东西得到更加牢固的掌握。本文通过三个部分来讲述这学期我们学习到的内容以及我们的实验成果。
1、简单网站的制作
制作网站是我们的第一个大作业,我们首先学习的是脚本语言制作简单网站。
HTML基础知识:
<br>表示换行;<meta>表示HTML网页文档的属性
<title>欢迎来到HTML的世界</title>//表示将“欢饮来到HTML世界”作为网页标题。
<font face=”楷体_GB3212” size=”2”>欢迎!</font>//设置字体
<p> </p>段落标签
<!—注释语句--->
有序列表
<ol>
<li>HTML简介</li>
<li>HTML基本标签</li>
<li>列表</li>
<li>多媒体和超链接</li>
<li>表格</li>
<li>框架</li>
<li>表单</li></ol>
表格
<table align="center"border="25"width="80%"bordercolor="yellow"cellpadding="1"background="D:\杨晋宇47\实验\wallpaper1.jpg"cellspacing="4">
<tr height ="50" valign="middle">
<th width="33%" colspan="2"><b>分组</b></th>
<th width="36%" colspan="2"><b>安排</b></th>
</tr>
<tr align="center" >
<td width="16%" ><b>甲方</b></td>
<td width="16%"><b>乙方</b></td>
<td width="17%"><b>时间</b> </td>
<td width="17%"><b>安排</b></td>
</tr>
<tr align="center">
<td width="16%">计算机应用</td>
<td widtn="16%">电子商务</td>
<td width="17%">12月5号下午</td>
<td width="17%">2号场地</td>
</tr>
<tr align="center">
<td width="16%">电子商务</td>
<td width="16%">管理</td>
<td width="17%">12月6号上午</td>
<td width="17%">1号球场</td>
</tr>
</table>
框架
<framesetcols="70%,*"frameboder="yes"border="10">
<framesetrows="60%,*"frameboder="yes">
<framesrc="top.html"name="top"scrolling="auto"norsize>
<framesrc="to.html"name="top"scrolling="auto"norsize>
</frameset>
<framesrc="right.html"name="right"scrolling="no"norsize>
<noframes>
锚点
<li><a href="#web">第一节 Web基础知识</a></li>
<li><a href="#JSP">第二节 JSP技术</a></li>
<li><a href="#tx">第三节 JSP开发Web的方式与体系结构</a></li>
<li><a href="#MCV">第四节 MVC设计模式</a></li>
<body bgcolor=yellow> //设置背景颜色
<body background=../img/background.gif> //设置背景图片
<p> 定义一个段落
<hr size=7 color=666666 width=80% align=right> //插入横线
超链接
<imgalt="不回家的女孩"src="D:\杨晋宇47\Web开发\《因特网编程技术》课程相关资料\实验素材及资料\girl.JPG"width="25%"align="middle" border="20">
根据这些知识点我做成了一个网站:
第二个大作业:学生成绩查询系统
1、 表单制作
<form name="form1" method="post" action="register.jap">
<h1 align="center">系统注册</h1> <br>
<center>
<p>姓名:<inputtype="text" name="username" align="center"></p>
<p>口令:<inputtype="password"name="password"align="center"></p>
<p>
<buttontype="submit ">登陆</button>
<buttontype ="reset ">重置 </button>
</center>
</form>
<form action="" name="form2" method="post">
<div align="center"> <font face="宋体" size="8" color="green">学生信息录入</font></div>
<center>
<p><fontface="黑体 "size="5">学号:</font><inputtype="text"align="middle">
<fontface="黑体"size="5">学生姓名:</font><inputtype="text">
<p><fontface="黑体"size="5">性别:</font><inputtype="radio">女性<inputtype="radio">男性
<fontface="黑体"size="5">考入省份:</font>
<selectname="provence"size="1">
<optionselected><fontsize="4">山西省</font>
<option>云南省</option>
<option>上海市</option>
<option>北京市</option>
<option>湖南省</option>
<option>海南省</option>
</select>
<p><fontface="黑体"size="5">特长: </font>篮球<inputtype="checkbox">排球<inputtype="checkbox">乐器<inputtype="checkbox">舞蹈<inputtype="checkbox">
<p><inputtype="submit"value="保 存"> <inputtype="reset"value="清 除">
</center>
</form>
2、 服务器脚本语言
<%Date day=new Date();
int d1=day.getDate();
int d2=day.getDay();
int d3=day.getMonth();
int d4=day.getYear();
int d=((d1-d2%7+7)%7);
int a=1,c=-d+1;
int e; %>
<%if(d3==1||d3==3||d3==5||d3==7||d3==8||d3==10||d3==12){
e=31;
}
elseif(d3==4||d3==6||d3==9||d3==11){
e=30;
}
else{
e=28;
} %>
<h1 align="center">20##年5月</h1>
<center>
<tableborder="3"width="168"height="81">
<tr>
<th width="25" height="16">一</th>
<th width="25" height="16">二</th>
<th width="25" height="16">三</th>
<th width="25" height="16">四</th>
<th width="25" height="16">五</th>
<th width="25" height="16"><font color="red">六</font></th>
<th width="25" height="16"><font color="red">日</font></th>
</tr>
<%for(int j=0;j<5;j++){%>
<tr>
<%for(int i=0;i<7;i++){ %>
<td>
<%if(a<=d){a++; %>
<%=""%>
<%} %>
<%if(c>=1&&c<=e&&c!=d1){ %>
<%=c %>
<%} %>
<%if(a>d&&c==d1){ %>
<font color="yellow"><%=c %></font>
<%}
c++;}
} %>
4.JSP数据库操作
String xueyuan=new String (request.getParameter("xueyuan").getBytes("ISO-8859-1"),"gb2312";String zhuanye=new String (request.getParameter("zhuanye").getBytes("ISO-8859-1"),"gb2312"); String xuehao=new String (request.getParameter("xuehao").getBytes("ISO-8859-1"),"gb2312");
String name=new String (request.getParameter("name").getBytes("ISO-8859-1"),"gb2312"); String sex=new String (request.getParameter("sex").getBytes("ISO-8859-1"),"gb2312");
String age=new String (request.getParameter("age").getBytes("ISO-8859-1"),"gb2312"); String sushe=new String (request.getParameter("sushe").getBytes("ISO-8859-1"),"gb2312"); String tel=new String (request.getParameter("tel").getBytes("ISO-8859-1"),"gb2312");
String jiguan=new String (request.getParameter("jiguan").getBytes("ISO-8859-1"),"gb2312"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:stuInfo10");
Statement stmt=con.createStatement();
String sql="insert into stuInfo10 values('','"+xueyuan+"','"+zhuanye+"','"+xuehao+"','"+name+"','"+sex+"','"+age+"','"+sushe+"','"+tel+"','"+jiguan+"')"; stmt.executeUpdate(sql); stmt.close(); con.close();18
插入数据的显示框
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:stuInfo10");
Statement stmt=con.createStatement();
String sql="select * from stuInfo10";
ResultSet rs=stmt.executeQuery(sql);
while (rs.next()){
%>
<tr>
<td><%= rs.getString("学院") %></td>
<td><%= rs.getString("专业") %></td>
<td><%= rs.getString("学号") %></td>
<td><%= rs.getString("姓名") %></td>
<td><%= rs.getString("性别") %></td>
<td><%= rs.getString("年龄") %></td>
<td><%= rs.getString("宿舍") %></td>
<td><%= rs.getString("电话") %></td>
<td><%= rs.getString("籍贯") %></td>
</tr>
<%} %>
<% out.print("查询access表成功!"); %>
<%
rs.close();
stmt.close();
con.close();
%>
</table>
</body>
5、大作业展示