jsp实验报告

时间:2024.4.7

    

教务系统

    班级:12级计本2班

                                                    姓名:于海涛

                                                        时间:20##年06月08日

教务系统

实验目的:

1、了解简单的HTML标记

2、掌握链接标记的使用

3、掌握表格标记的使用

4、掌握表格嵌套的使用

5、简单的HTML<script>标签使用

6、Servlet的应用

7、Mov模式实例化

8、验证码技术->java绘图Graphics的使用+java随机函数Random()+javaIO

9、Jsp网页跳转

10、下载提示框

11、验证码验证 jsp内对象session的使用

实验环境:

1、jdk-6.0

2、apache-tomcat-6.0

3、Myeclipse-10.0

实验思想:

1、新建登陆页zhuyemian.jsp,表格嵌入表单,元素:用户名、密码,验证码。通过script验证,账号1111,密码1234,提交给ser01.java;

2、通过session获取提交的验证码和code.jsp生成的随机函数是否一致,一致转到neizhuye.jsp,否则返回zhuyemian.jsp;

3、主页包括neizhuye.jsp xuanke.jsp chengji.jsp pingjiao.jsp搭建统一框架;

4、主页通过onclick 和 <script>function 实现4个页面之间的转换,和退出到zhuyemian.jsp。并且内置各种按钮和嵌套表格 。

实验目录: 

实验展示:

1、登陆页

 

2、主页

实验代码:

zhuyemiam.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>

<html>

  <body align="center" style="background:url('image/01.jpg') no-repeat;">

  <script type="text/javascript">

      function check(){

          if(form1.mingzi.value==""){

              alert("账号不能为空");

              return;

          }

          if(form1.password.value==""){

              alert("密码不能为空");

              return;

          }

         

          if(form1.mingzi.value!="1111"){

              alert("账号错啦");

              return;

          }

         

          if(form1.password.value!="1234"){

              alert("密码错啦");

              return;

          }

          form1.submit();

      }

  </script>

  <br> <br> <br>

  <form name="form1" action="servlet/ser01" method="post">

 

  <table border="0" borsercolor="black" cellspacing="0" cellpadding="0" align="center" width="900" height="400">

 

  <tr>

  <td width="450" height="400">  <img width="100%" height="273" align="center" src="image/03.jpg"></td>

 

  <td width="450" height="100%">

  <table  style="background:url('image/05.jpg') no-repeat;" width="100%" height="313">

       <tr> <td height="28%"> </td>    </tr>

      

      <tr>

         <td width="120" align="right"><img  src="image/011.png"></td>

         <td width="60" align="center" style="color:blue">用户名: </td>

         <td colspan="2"><input type="text" name="mingzi" size="15"> </td>  

      </tr>

     

      <tr>

         <td width="120" align="right"><img  src="image/002.png"></td>

             <td width="60" align="center" style="color:blue">密  码 :</td>

              <td colspan="2"><input type="password" name="password" size="15"> </td>

        </tr>

 

        <tr>

            <td width="120" align="right"><img  src="image/003.png"></td>

               <td width="60" align="center" style="color:blue">验证码: </td>

               <td><input  type="text" size="10" name="ma"> </td>

               <td align="left"><img name="valimg" src="code.jsp">  <a href="zhuyemian.jsp">刷新</a> </td>

      </tr>

      <tr>

          <td > </td>

          <td align="right"><input type="button" value="提交" onClick="check()"> </td>

          <td><input type="reset" value="取消"></td>

      </tr>

      <tr> <td height="15%"> </td>    </tr>

   </table>

  </td>

  </tr>

       </table>

       </form>

<br>

 <table align="center" style="font-size:15px;">

    <tr>

       <td align="center" style="color:green">  时间:20##年06月05日-------版权所有:12级计本2班-------联系电话:0451-********  </td>

    </tr>

    </table>

       </body>

</html>

ser01.java

package pack01;

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

public class ser01 extends HttpServlet {

       /**

        * Constructor of the object.

        */

       public ser01() {

              super();

       }

       /**

        * Destruction of the servlet. <br>

        */

       public void destroy() {

              super.destroy(); // Just puts "destroy" string in log

              // Put your code here

       }

       /**

        * The doGet method of the servlet. <br>

        *

        * This method is called when a form has its tag value method equals to get.

        *

        * @param request the request send by the client to the server

        * @param response the response send by the server to the client

        * @throws ServletException if an error occurred

        * @throws IOException if an error occurred

        */

       public void doGet(HttpServletRequest request, HttpServletResponse response)

                     throws ServletException, IOException {

              response.setContentType("text/html");

              response.setCharacterEncoding("gbk");

              PrintWriter out = response.getWriter();

             

              String code = request.getParameter("ma");

              HttpSession session = request.getSession();

              String randStr = (String)session.getAttribute("randStr");

             

              if(!code.equals(randStr)){

                     response.sendRedirect("/haitao/zhuyemian.jsp");

              }

              else{

                     out.print("验证通过,正在跳转");

                     response.sendRedirect("/haitao/neizhuye.jsp");

              }

                    

              out.flush();

              out.close();

       }

       private void alert(String string) {

              // TODO Auto-generated method stub

             

       }

       /**

        * The doPost method of the servlet. <br>

        *

        * This method is called when a form has its tag value method equals to post.

        *

        * @param request the request send by the client to the server

        * @param response the response send by the server to the client

        * @throws ServletException if an error occurred

        * @throws IOException if an error occurred

        */

       public void doPost(HttpServletRequest request, HttpServletResponse response)

                     throws ServletException, IOException {

              this.doGet(request, response);

       }

       /**

        * Initialization of the servlet. <br>

        *

        * @throws ServletException if an error occurs

        */

       public void init() throws ServletException {

              // Put your code here

       }

}

serdowload.java

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class serdownload extends HttpServlet {

       /**

        * Constructor of the object.

        */

       public serdownload() {

              super();

       }

       /**

        * Destruction of the servlet. <br>

        */

       public void destroy() {

              super.destroy(); // Just puts "destroy" string in log

              // Put your code here

       }

       /**

        * The doGet method of the servlet. <br>

        *

        * This method is called when a form has its tag value method equals to get.

        *

        * @param request the request send by the client to the server

        * @param response the response send by the server to the client

        * @throws ServletException if an error occurred

        * @throws IOException if an error occurred

        */

       public void doGet(HttpServletRequest request, HttpServletResponse response)

                     throws ServletException, IOException {

              String filename = request.getParameter("file");

             

              response.setHeader("Content-Disposition", "attachment;filename="+filename);

              response.setContentType("image/jpeg");

             

              RequestDispatcher rd = request.getRequestDispatcher("/image/"+filename);

             

              rd.forward(request, response);

       }

       /**

        * The doPost method of the servlet. <br>

        *

        * This method is called when a form has its tag value method equals to post.

        *

        * @param request the request send by the client to the server

        * @param response the response send by the server to the client

        * @throws ServletException if an error occurred

        * @throws IOException if an error occurred

        */

       public void doPost(HttpServletRequest request, HttpServletResponse response)

                     throws ServletException, IOException {

              this.doGet(request, response);

       }

       /**

        * Initialization of the servlet. <br>

        *

        * @throws ServletException if an error occurs

        */

       public void init() throws ServletException {

              // Put your code here

       }

}

code.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>

<%@ page import="java.awt.*" %>

<%@ page import="java.awt.image.BufferedImage" %>

<%@ page import="javax.imageio.ImageIO" %>

<%

       response.setHeader("Cache-Control", "no-cache");

       int width=60,height=20;

       BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);

      

       Graphics g= image.getGraphics();

       g.setColor(new Color(200,200,200));

       g.fillRect(0, 0, width, height);

      

       Random rnd = new Random();

       int randNum = rnd.nextInt(8999)+1000;

       String randStr = String.valueOf(randNum);

      

       session.setAttribute("randStr", randStr);

       g.setColor(Color.black);

       g.setFont(new Font("",Font.PLAIN,20));

       g.drawString(randStr, 10, 17);

      

       for(int i=0;i<100;i++){

              int x = rnd.nextInt(width);

              int y = rnd.nextInt(height);

              g.drawOval(x, y, 1, 1);

             

       }

      

       ImageIO.write(image, "JPEG", response.getOutputStream());

      

       out.clear();

       out = pageContext.pushBody();

%>

chengji.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>

<html>

<body>

       <script>

              function sm1() {

                     document.form1.action = "neizhuye.jsp";

                     document.form1.submit();

              }

              function sm2() {

                     document.form1.action = "xuanke.jsp";

                     document.form1.submit();

              }

              function sm3() {

                     document.form1.action = "chengji.jsp";

                     document.form1.submit();

              }

              function sm4() {

                     document.form1.action = "pingjia.jsp";

                     document.form1.submit();

              }

              function sm5() {

                     document.form1.action = "zhuyemian.jsp";

                     document.form1.submit();

              }

       </script>

<body>

       <form name="form1" method="post">

              <table border="8" borderColor="#51a8ff" width="100%" height="100%"

                     bgColor="#ecf5ff">

                     <tr>

                            <td align="right" height="11%"

                                   style="background:url('image/06.jpg') no-repeat;" colspan="5"><input

                                   type="button" onclick="sm5()" value="退出">

                            </td>

                     </tr>

                     <tr>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm1()">返回首页</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm2()">课程安排</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm3()">成绩查询</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm4()">教师评价</td>

                            <td bgColor="#c8e3ff" height="3%" width="50%"></td>

                     </tr>

                     <tr>

                            <td height="5%" colspan="5" style="color:red"><img

                                   src="image/004.png">当前位置-----------成绩查询</td>

                     </tr>

                     <tr>

                            <td height="81%" colspan="8" valign="top">

                                   <table height="10%" width="100%" bgColor="#f7ffff">

                                          <tr>

                                                 <td width="12%">学年: <select name="xuenian">

                                                               <option>20##-2013</option>

                                                               <option>20##-2014</option>

                                                 </select></td>

                                                 <td width="10%">学期: <select name="xueqi">

                                                               <option>1</option>

                                                               <option>2</option>

                                                 </select></td>

                                                 <td width="90%"><input type="button" value="查询"></td>

                                          </tr>

                                   </table>

                                   <table height="90%" width="100%" border="2" bordercolor="blue"

                                          bgColor="#eeeff">

                                          <tr>

                                                 <td align="center" height="20%" width="25%">课程号</td>

                                                 <td align="center" height="20%" width="25%">课程名</td>

                                                 <td align="center" height="20%" width="25%">成绩</td>

                                                 <td align="center" height="20%" width="25%">任课老师</td>

                                          </tr>

                                          <tr>

                                                 <td align="center" height="20%" width="25%"></td>

                                                 <td height="20%" width="25%"> </td>

                                                 <td height="20%" width="25%"> </td>

                                                 <td height="20%" width="25%"> </td>

                                          </tr>

                                          <tr>

                                                 <td align="center" height="20%" width="25%"></td>

                                                 <td height="20%" width="25%"> </td>

                                                 <td height="20%" width="25%"> </td>

                                                 <td height="20%" width="25%"> </td>

                                          </tr>

                                          <tr>

                                                 <td align="center" height="20%" width="25%"></td>

                                                 <td height="20%" width="25%"> </td>

                                                 <td height="20%" width="25%"> </td>

                                                 <td height="20%" width="25%"> </td>

                                          </tr>

                                          <tr>

                                                 <td align="center" height="20%" width="25%"></td>

                                                 <td height="20%" width="25%"> </td>

                                                 <td height="20%" width="25%"> </td>

                                                 <td height="20%" width="25%"> </td>

                                          </tr>

                                   </table></td>

                     </tr>

              </table>

</body>

</html>

neizhuye.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>

<html>

<body>

       <script>

              function sm1() {

                     document.form1.action = "neizhuye.jsp";

                     document.form1.submit();

              }

              function sm2() {

                     document.form1.action = "xuanke.jsp";

                     document.form1.submit();

              }

              function sm3() {

                     document.form1.action = "chengji.jsp";

                     document.form1.submit();

              }

              function sm4() {

                     document.form1.action = "pingjia.jsp";

                     document.form1.submit();

              }

              function sm5() {

                     document.form1.action = "zhuyemian.jsp";

                     document.form1.submit();

              }

       </script>

<body>

       <form name="form1" method="post">

              <table border="8" borderColor="#51a8ff" width="100%" height="100%"

                     bgColor="#ecf5ff">

                     <tr>

                            <td align="right" height="11%"

                                   style="background:url('image/06.jpg') no-repeat;" colspan="5"><input

                                   type="button" onclick="sm5()" value="退出">

                            </td>

                     </tr>

                     <tr>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm1()">返回首页</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm2()">课程安排</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm3()">成绩查询</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm4()">教师评价</td>

                            <td bgColor="#c8e3ff" height="3%" width="50%"></td>

                     </tr>

                     <tr>

                            <td height="5%" colspan="5" style="color:red"><img

                                   src="image/004.png">当前位置-----------首页</td>

                     </tr>

                     <tr>

                            <td height="81%" colspan="8" align="center" style="font-size:100px;">欢迎使用教务管理系统</td>

                     </tr>

              </table>

</body>

</html>

xuanke.jsp

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>

<html>

<body>

       <script>

              function sm1() {

                     document.form1.action = "neizhuye.jsp";

                     document.form1.submit();

              }

              function sm2() {

                     document.form1.action = "xuanke.jsp";

                     document.form1.submit();

              }

              function sm3() {

                     document.form1.action = "chengji.jsp";

                     document.form1.submit();

              }

              function sm4() {

                     document.form1.action = "pingjia.jsp";

                     document.form1.submit();

              }

              function sm5() {

                     document.form1.action = "zhuyemian.jsp";

                     document.form1.submit();

              }

       </script>

<body>

       <form name="form1" method="post">

              <table border="8" borderColor="#51a8ff" width="100%" height="100%"

                     bgColor="#ecf5ff">

                     <tr>

                            <td align="right" height="11%"

                                   style="background:url('image/06.jpg') no-repeat;" colspan="5"><input

                                   type="button" onclick="sm5()" value="退出">

                            </td>

                     </tr>

                     <tr>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm1()">返回首页</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm2()">课程安排</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm3()">成绩查询</td>

                            <td bgColor="#c8e3ff" style="color:blue" height="3%" width="12.5%"

                                   align="center" onclick="sm4()">教师评价</td>

                            <td bgColor="#c8e3ff" height="3%" width="50%"></td>

                     </tr>

                     <tr>

                            <td height="5%" colspan="5" style="color:red"><img

                                   src="image/004.png">当前位置-----------课程安排</td>

                     </tr>

                     <tr>

                            <td height="81%" align="center" colspan=5 style="font-size:50px;">

                                   <a href="/haitao/servlet/serdownload?file=kebiao.jpg">下载此课程表 </a> <br>

                                   <img src="image/kebiao.jpg"></td>

                     </tr>

              </table>

</body>

</html>

                    

更多相关推荐:
spss实验报告

湖北汽车工业学院SPSS实习报告学号20xx0530501姓名杨文弟指导教师彭娟娟曾智实验一描述性统计分析一实验目的利用SPSS进行描述性统计分析要求掌握频数分析Frequencies过程描述性分析Descri...

spss对数据进行相关性分析实验报告

管理统计实验报告实验一一实验目的掌握用spss软件对数据进行相关性分析熟悉其操作过程并能分析其结果二实验原理相关性分析是考察两个变量之间线性关系的一种统计分析方法更精确地说当一个变量发生变化时另一个变量如何变化...

spss实验报告1

统计分析与SPSS的应用实验报告一一数据来源及说明本次试验报告数据来源于19xx年美国社会变迁普查19xxUSGeneralSocialSurvey在这次试验研究的是美国居民幸福感状况分析性别种族和地区之间的差...

spss实验报告模板

实验报告实验三连续变量的统计描述与参数估计实验目的1了解连续变量的统计描述指标体系和参数估计指标体系2掌握具体案例的统计描述和分析3学会bootstrap等方法实验原理1spss的许多模块均可完成统计描述的任务...

统计分析spss实验报告

国际商学院实验报告专业班级姓名学号成绩备注因实验项目不同表格不够可加附页实验结果若是网上提交请注明

spss实验报告

线订号学名姓装级班1234567891011121314151617

spss实验报告三

实验报告三一实验项目均数间的比较二实验的目的运用SPSS软件进行均数间的比较并能掌握运用SPSS软件的进行假设检验三实验内容1均值2单样本T检验3两独立样本T检验4配对样本T检验一均值1均值表示一系列数据或统计...

Spss实验总结

Spss总结本学期一共学习了七项spss使用方法分别是数据整理数据的转换t检验方差分析卡方检验相关分析与回归方程图表的制作与编辑我觉得spss对我用处非常大就平时学习来说我用它计算了几道生物统计题完成了spss...

spss实验报告

武汉工商学院市场调查与预测课程实验实训报告武汉工商学院武汉工商学院

spss统计学上机报告

一用两种定义变量的方法绘制直方图某学院两个专业各抽取24名学生他们某门课考试成绩资料如下方法1SPSS操作步骤定义成绩学生数和专业三个变量在定义变量窗口对专业做变量值标签令1甲专业2乙专业在录入数据窗口依次录入...

管理统计spss数据管理-实验报告

数据管理一实验目的与要求1掌握计算新变量变量取值重编码的基本操作2掌握记录排序拆分筛选加权以及数据汇总的操作3了解数据字典的定义和使用数据文件的重新排列转置合并的操作二实验内容提要1自行练习完成课本中涉及的对C...

管理统计学spss数据的录入及获取-实验报告

数据的录入及获取一实验目的与要求1熟悉软件数据录入界面的操作说明2掌握开放题单选题多选题的录入方法3掌握如何将电子表格数据文本数据数据库格式数据导入到SPSS中4熟悉数据保存方法二实验内容提要1根据给定的调查问...

spss实验报告(9篇)