网站设计实习报告

时间:2024.3.31

经济管理学院信息管理与信息系统专业

网站设计实习

200200学年)

            设计名称: 心连心聊天室

                  --------------------------

          班    级: 信管082班

                               ----------------------

          姓    名:苏文鹏(组长)、宋廷雪、周淑珍、刘文英

                             ---------------------———————————————————

          指导教师: 信管教研室

                                 ---------------------

        成    绩:

                                ----------------------

              地    点: 经管院实验室

                   -------------

         序    号62016157

                           

                 二010年  1 月  8 日

一、综述

 随着互连网应用的不断深入,人们用来交流和联络的工具已经越来越多,其中网络聊天室是用户比较喜欢的一种WEB应用程序,借助聊天室和他的留言系统,用户可以及时互通信息,交流思想.本系统主要采用了基于B/S(Browser/Server,即浏览器/服务器)模式开发的简易聊天室系统。本系统是采用了JSP技术开发的动态网站。系统开发主要包括前台界面及其功能设计和后台数据库设计(即发言区管理和用户管理)。

二、网站设计的思想

本系统采用了JSP 作为开发工具,后台数据库采用了数据库设计,利用JDBC数据库访问技术实现对数据库的各种管理操作,实现了聊天室的聊天功能和显示在线聊天用户信息的功能。在设计过程中,首先建立了系统的应用模型,然后在此基础上再进行需求分析逐步进行各功能的设计实现。在详细设计时经过不断的修正和完善,经过测试阶段反复调试和验证,最终形成达到了设计要求的可行系统。

三、数据库结构及SQL脚本程序

1、数据库结构

数据库test

表名abu:

2、用户登陆后的检测页面(loginchek.jsp)中,通过javabean与数据库连接,脚本语言为:

 package test;

import java.sql.*;

public class sqlbean{

private Connection conn;

private ResultSet rs;

public Connection getConnection() throws SQLException{

Connection con=null;

try{

Class.forName("com.mysql.jdbc.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost/test","root","111");

}

catch(Exception e4)

{

System.out.println("没有连接成功!"+e4);

}

return con;

}

public ResultSet executeQuery(String sql){

try{

conn=getConnection();

Statement st=conn.createStatement();

rs=st.executeQuery(sql);

}

catch(Exception e1)

{

System.out.println("查询出现异常");

}

return rs;

}

public int executeUpdate(String sql)

{

int count=0;

Statement stmt=null;

try{

conn=getConnection();

stmt=conn.createStatement();

count=stmt.executeUpdate(sql);

}

catch(SQLException e2){

System.out.println("更新出现异常!");

}

return count;

}

public void freeRs(ResultSet rs){

try{

if(rs!=null){

rs.close();

conn.close();

}

}

catch(Exception e3){

System.out.println("关闭异常");

}

}

}

3、用户注册(4.html)后的检测页面(two.jsp)中SQL脚本语言为:

Class.forName("com.mysql.jdbc.Driver");

String url="jdbc:mysql://localhost/test";

String user="root";

String pas="111";

Connection conn=DriverManager.getConnection(url,user,pas);

String sql="select username from abu where username='"+username+"' and password='"+password+"'";

Statement stmt=conn.createStatement();

ResultSet rs=stmt.executeQuery(sql);

4、连接数据库的脚本文件

<%

// FileName="mysql_jdbc_conn.htm"

// Type="JDBC" ""

// DesigntimeType="JDBC"

// HTTP="true"

// Catalog=""

// Schema=""

String MM_myconn_DRIVER = "com.mysql.jdbc.Driver";

String MM_myconn_USERNAME = "root";

String MM_myconn_PASSWORD = "111";

String MM_myconn_STRING = "jdbc:mysql://localhost/test";

%>

四、网站结构图

                   

                                 Y           N

五、各个网页的功能及各个功能模块之间的关系

login.jsp:登陆模块 

logincheck.jsp:与数据库连接检测是否登陆成功

4.html:注册页面  

two.jsp:提交数据后跳转到数据库,然直接返回登录界面

chat.jsp::聊天主界面 

input.jsp:输入聊天内容

show.jsp:显示聊天内容

transact.jsp:用来连接chat.jsp与input.jsp,将输入的内容能够显示在聊天主界面上

若登陆成功,则跳转至聊天主界面,若数据库中无此用户,则提示错误“用户名或密码错误”登陆失败,返回登陆界面进行新用户注册。

六、JSP源程序

1login.jsp

<%@page contentType="text/html;charset=GBK"%>

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

<html>

<head>

<title>用户登陆</title>

<style type="text/css">

<!--

.STYLE1 {

       font-size: 14px;

       color: #000000;

}

.STYLE2 {

       font-size: 18px;

       font-family: "Courier New", Courier, monospace;

       color: #F50A3F;

       font-weight: bold;

       font-style: italic;

}

.STYLE3 {font-size: 18px}

.STYLE4 {font-size: 16px}

-->

</style>

<script language="javascript">

function checkForm() {

       if (document.form1.username.value == "") {

              alert("用户名不能为空");

              form1.username.focus();

              return false;

       }

       document.form1.submit();

}

function check1Form()

{

       alert("用户名不能为空");

}

</script>

<link href="css/chat.css" rel="stylesheet" type="text/css">

</head>

<body background="images/23.jpg">

<br>

<table align="center">

  <tr>

    <td width="93%" align="right"><H1></H1></td>

   </td>

  </tr>

</table>

<br>

<table width="100" border="0" cellspacing="0" cellpadding="0" align="center">

  <tr>

  </tr>

  <tr align="center" valign="middle">

    <td>

      <form name="form1" method="post" action="logincheck.jsp">

        <table border="1" cellpadding="0" bordercolor="#0099FF" align="center">

<tr>

<td width="599">

<table width="349" border="0" cellpadding="0">

  <tr>

    <td height="33" colspan="2"><div align="center"><span class="STYLE3">用户登录</span></div></td>

  </tr>

  <tr>

    <td width="80" height="30" align="left" nowrap="nowrap"><span class="STYLE4">用户名  </span></td>

   <td width="308"><input type="text" name="username" maxlength="8" width="175" height="20" /></td>

  </tr>

  <tr>

    <td width="80" height="25" align="left" valign="middle" nowrap="nowrap"><span class="STYLE4"></span></td>

    <td><input name="password"  type="password" maxlength="12" width="175"  height="20" /></td>

  </tr>

 <tr>

    <td colspan="2">

      <div align="center">

         <input type="button" value="登陆" onClick="checkForm();" style="cursor:hand" alt="">

         &nbsp;<a href="4.html">新用户注册</a></div>       </td>

  </tr>

  <tr>

    <td height="61" colspan="2"><img src="images/bottom.jpg" width="347" height="61"></td>

  </tr></table>

</td></tr>

</table>

</form>

</td></tr>

</table>

</body>

</html>

运行结果:

2logincheck.jsp

<%@page contentType="text/html;charset=GBK"%>

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

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

<html>

<head>

<title>登录检查</title>

</head>

<body>

<body>

<%

String regName=request.getParameter("username");

String regPassword=request.getParameter("password");

session.setAttribute("originname",regName);

Class.forName("com.mysql.jdbc.Driver");

String url="jdbc:mysql://localhost/test";

String user="root";

String pas="111";

Connection conn=DriverManager.getConnection(url,user,pas);

String sql="select username from abu where username='"+regName+"' and password='"+regPassword+"'";

Statement stmt=conn.createStatement();

ResultSet rs=stmt.executeQuery(sql);

if(rs.next())

{

  session.setAttribute("username",regName);

     rs.close();

response.sendRedirect("chat.jsp");

}

else

{

out.print("<script language='javaScript'>");

out.print("alert('用户名或者密码错误');");

out.print("window.location.href='login.jsp'");

out.print("</script>");

}

%>

</body>

</html>

34.html

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<script language="javascript">

<!--

function CheckForm(){

              

                if (document.form1.text1.value== "") {

                   alert("姓名不能为空!");

                    document.form1.text1.focus();

                    return false;

                }

                if (document.form1.password1.value.length<6) {

                    alert("密码不为空或小于6");

                    document.form1.password1.focus();

                                     document.form1.password1.select();

                    return false;

                }

    if (document.form1.password2.value.length<6) {

                    alert("密码不为空或小于6");

                    document.form1.password2.focus();

                                     document.form1.password2.select();

                    return false;

                }

                if (document.form1.password2.value!= document.form1.password1.value) {

                    alert("输入密码和确认密码不一致");

                                   document.form1.password2.focus();

                    document.form1.password2.select();

                    return false;

                }

             var sw = document.form1.text2.value.indexOf("@", 0);

                var sw1 = document.form1.text2.value.indexOf(".", 0);

                var tt = sw1 - sw;

                if (document.form1.text2.value.length == 0) {

                    alert("电子邮件不能为空");

                    document.form1.text2.focus();

                    return false;

                }

                if (document.form1.text2.value.indexOf("@", 0) == -1) {

                    alert("电子邮件格式不正确,必须包含@符号!");

                    document.form1.text2.select();

                    return false;

                }

                if (document.form1.text2.value.indexOf(".", 0) == -1) {

                    alert("电子邮件格式不正确,必须包含.符号!");

                    document.form1.text5.select();

                    return false;

                }

                if (tt == 1) {

                    alert("邮件格式不对。@.不可以挨着!");

                    document.form1.text2.select();

                    return false;

                }

                if (sw > sw1) {

                    div.innerHTML = "电子邮件格式不正确,@符号必须在.之前";

                    document.form1.text2.select();

                    return false;

                }

}

//-->

</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>用户注册</title>

</head>

<body topmargin="0" background="images/12.jpg">

<form id="form1" name="form1" method="post" action="two.jsp"style=" background-image:url(file">

  <table width="1039" height="695"  border="0" align="center" cellpadding="0" cellspacing="0" >

    <tr>

      <td width="18%"height="40" align="right"> 用户名: </td>

      <td><input maxlength="6" type="text" name="text1" onblur="check()" />

 </td> </tr><tr>

      <td width="18%" height="40" align="right">性 别:</td>

      <td><input id="sex" name="sex" type="radio" value="" checked />

        男  

        <input id="sex" name="sex" type="radio" value="" />

        </td>

      <td colspan="2">  </td>

    </tr>

    <tr>

      <td height="40" align="right"> 密码: </td>

      <td><input name="password1" type="password" maxlength="12" onblur="check()" />

          <div id="div2" style="display:inline"> </div>

      </td>

    </tr>

    <tr>

      <td height="40" align="right"> 确认密码: </td>

      <td><input type="password" name="password2" onblur="check()" />

          <div id="div3" style="display:inline"> </div>

      </td>

    </tr>

    <tr>

      <td height="40" align="right"> 电子邮件地址: </td>

      <td><input id="text2" type="text" name="text2" onblur="check()" />

          <div id="div4" style="display:inline"> </div>

      </td>

    </tr>

    <tr>

      <td width="18%" height="40" align="right"> 生 日:</td>

      <td><select  name="selYear" size="1">

          <option>1980</option>

        <option>1981</option>

          <option>1982</option>

        <option selected="selected" >1983</option>

        <option>1984</option>

        <option>1985</option>

        <option>1986</option>

          <option>1987</option>

        <option>1988</option>

        <option>1989</option>

          <option>1990</option>

          <option>1991</option>

          <option>1992</option>

        <option>1993</option>

        <option>1994</option>

        </select>

          <select id="selMonth" name="selMonth">

            <option>1</option>

            <option>2</option>

            <option>3</option>

            <option>4</option>

            <option>5</option>

            <option>6</option>

            <option>7</option>

            <option>8</option>

            <option>9</option>

            <option>10</option>

            <option>11</option>

            <option>12</option>

          </select>

          <select name="selDay" size="1" id="selDay">

            <option>1</option>

            <option>2</option>

            <option>3</option>

            <option>4</option>

            <option>5</option>

            <option>6</option>

            <option>7</option>

            <option>8</option>

            <option>9</option>

            <option>10</option>

            <option>11</option>

            <option>12</option>

            <option>13</option>

            <option>14</option>

            <option>15</option>

            <option>16</option>

            <option>17</option>

            <option>18</option>

            <option>19</option>

            <option>20</option>

            <option>21</option>

            <option>22</option>

            <option>23</option>

            <option>24</option>

            <option>25</option>

            <option>26</option>

            <option>27</option>

            <option>28</option>

            <option>29</option>

            <option>30</option>

          </select>

      </td> </tr><tr>

      <td width="18%" height="40" align="right">所在地:</td>

      <td width="31%"><input id="name" name="name" type="text" onblur="javascript:return un();" class="Input" value="" /></td>

    </tr>

    <tr>

      <td width="18%" height="40" align="right">联系电话:</td>

      <td width="31%"><input id="name" name="name" type="text" onblur="javascript:return un();" class="Input" value="" /></td>

    </tr>

    <tr>

      <td width="18%" height="40" align="right">邮箱:</td>

      <td width="31%"><input id="name" name="name" type="text" onblur="javascript:return un();" class="Input" value="" /></td>

    </tr>

    <tr>

      <td width="18%" height="53" align="right">联系地址:</td>

      <td width="31%" height="53"><input id="name" name="name" type="text" onblur="javascript:return un();" class="Input" value="" /></td>

    </tr>

    <tr align="center">

      <td height="60" colspan="2" align="right"><input type="submit" onclick="javascript:return CheckForm();" value="提交注册" name="B1" />

          <input type="reset" value="重置" name="text7" /></td>

    </tr>

  </table>

</form>

</body>

</html>

运行结果:

注册界面

                   

4chat.jsp

<HTML>

<HEAD>

<%@ page

language="java"

contentType="text/html; charset=GB2312"

pageEncoding="GB2312"

%>

<META http-equiv="Content-Type" content="text/html; charset=GB2312">

<title>聊天室</title>

</head>

<frameset rows = "*,100"     >

       <frameset cols = "*,150" >

             <frame src = "show.jsp" name="mainFrame" scrolling="auto">

              <frameset rows = "132,53%,0" >

                     <frame name = "image"  src="images/wolf.gif">

                     <frame name = "hiddenFrame" src="transact.jsp">

              <frame src="UntitledFrame-3.html"></frameset>

       </frameset>

  <frame src="input.jsp?username=<%= session.getAttribute("username") %>" name="inputFrame">

</frameset>

<noframes>

<body bgcolor="#FFFFFF">

您的浏览器不支持框架,对不起!

</body>

</noframes>

</html>

5input.jsp

<HTML>

<HEAD>

<%@ page

language="java"

contentType="text/html; charset=GB2312"

pageEncoding="GB2312"

%>

<META http-equiv="Content-Type" content="text/html; charset=GB2312">

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

<link rel="stylesheet" href="chat.css">

<script language="JavaScript" type="">

function checkForm() {

       if (document.chatForm.usermessage.value == "") {

              alert("发言不能为空!");

              document.chatForm.usermessage.focus();

              return false;

       }

       else {

              document.chatForm.usermessage.focus();

              return true;

       }

}

function userLogout() {

       top.window.location="login.jsp?logout=yes";

}

function openWindow(url) {

       varnewWin= window.open(url,"","toolbar=no,status=no,scrollbars=yes,menubar=no,width=450,height=320");

       return false;

}

</script>

</HEAD>

<BODY bgcolor="#B0D5F4" >

<FORM name="chatForm"  method="post" action="input.jsp">

<table border="0" width="100%" align="center" cellspacing="0" cellpadding="0">

<tr valign="top"><td>

<%

request.setCharacterEncoding("gb2312");

String first = (String)request.getParameter("first");

String talkMessage=(String)request.getParameter("usermessage");

String action = (String)request.getParameter("action");

String fontcolor = (String) request.getParameter("fontcolor");

String talkwith =(String)request.getParameter("talkwith");

String systemSpeak=(String) request.getParameter("systemSpeak");

String Name=(String)session.getAttribute("username");

session.setAttribute("sName",Name);

out.println("<font color='#0000ff'>"+Name+"</font>"+"");

//用户第一次进入,初始化状态

if (first == null) {

       talkMessage="系统公告:<font color = blue>"+Name+"</font>进入了聊天室,大家欢迎!";

       action = "no";

       fontcolor = "#000000";

       systemSpeak = "yes";

}

if(talkwith==null) {

        talkwith = "所有人";

}

%>

 <input type="text" name="talkwith" value= <%= talkwith %> size="8" style="font-size:9pt">

        动作

        <select name="action" size="1" style="font-size:9pt">

          <option value="no" selected>说话</option>

          <option value="友好地拉着B的手说:">问好</option>

          <option value="B会意地点点头,说:">点头</option>

          <option value="B妩媚地甜甜一笑,说:">妩媚</option>

          <option value="万事不萦于心地呵呵笑着对B说:">开朗</option>

          <option value="一脸的坏笑,不怀好意地打量着B,说:">坏笑</option>

          <option value="忍住泪水,强挤出一丝笑容对B说:">苦笑</option>

          <option value="白了B一眼,十分不屑地说:">白眼</option>

          <option value="轻轻地在B的额头上吻了一下,温柔地说:">轻吻</option>

          <option value="热烈地拥抱着B,几乎透不过气来,说:">拥抱</option>

          <option value="含情脉脉地凝视着B说:">深情</option>

          <option value="泪珠儿在眼眶里打转,无限伤心地对B说:">伤心</option>

          <option value="羞红了脸,拧过身子背对着B说:">害羞</option>

          <option value="气得全身发抖,两眼喷火瞪着B,说:">愤怒</option>

          <option value="B招招手,中间夹了个飞吻,说:">招手</option>

          <option value="嘟着嘴哼哼哧哧地对B说:">不满</option>

          <option value="兴奋得不得了,对着B翩翩起舞,说:">兴奋</option>

          <option value="情不自禁地搂着B热吻起来,还叽哩咕噜地说:">狂吻</option>

          <option value="泪光闪闪看着B,脸上写满了委屈的说:">委屈</option>

          <option value="急得直跺脚,气急败坏地对B说:">着急</option>

          <option value="泪如泉涌,对着B哗啦哗啦哭了起来,说:">嚎啕</option>

          <option value="皱起眉头别转脸,却又偷看B一眼,故作生气说:">撒娇</option>

          <option value="眯起斗鸡眼看着B一阵奸笑说:">奸笑</option>

          <option value="突然跃起飞脚猛踢B屁股,说:">飞脚</option>

          <option value="左右开弓抽得B满地找牙,说:">抽掴</option>

          <option value="B皮笑肉不笑地说:">假笑</option>

        </select>

        <input type="hidden" name="first" value="first">

        <input type="hidden" name="systemSpeak" value="no">

<%

String aloneTalk=request.getParameter("alonetalk");

if(aloneTalk==null)

aloneTalk="no";

if(aloneTalk.equals("no"))

out.print("<input type=\"checkbox\" name=\"alonetalk\" value=\"yes\" > 悄悄话 ");

else

out.print("<input type=\"checkbox\" name=\"alonetalk\" value=\"yes\" checked > 悄悄话");

%>

 <input type="text" name="usermessage" size=50 style="font-size:9pt">

        <select name="fontcolor" size="1" style="font-size:9pt">

          <option style="COLOR: #000000" value="#000000" <% if(fontcolor.equals("#000000")) out.print("selected"); %>>黑色

          <option style="COLOR: #7ec0ee" value="#7ec0ee" <% if(fontcolor.equals("#7ec0ee")) out.print("selected"); %>>淡蓝

          <option style="COLOR: #0088ff" value="#0088ff" <% if(fontcolor.equals("#0088ff")) out.print("selected"); %>>海蓝

          <option style="COLOR: #0000ff" value="#0000ff" <% if(fontcolor.equals("#0000ff")) out.print("selected"); %>>草蓝

          <option style="COLOR: #000088" value="#000088" <% if(fontcolor.equals("#000088")) out.print("selected"); %>>深蓝

          <option style="COLOR: #8800ff" value="#8800ff" <% if(fontcolor.equals("#8800ff")) out.print("selected"); %>>蓝紫

          <option style="COLOR: #ab82ff" value="#AB82FF" <% if(fontcolor.equals("#AB82FF")) out.print("selected"); %>>紫色

          <option style="COLOR: #ff88ff" value="#ff88ff" <% if(fontcolor.equals("#ff88ff")) out.print("selected"); %>>紫金

          <option style="COLOR: #ff00ff" value="#ff00ff" <% if(fontcolor.equals("#ff00ff")) out.print("selected"); %>>红紫

          <option style="COLOR: #ff0088" value="#ff0088" <% if(fontcolor.equals("#ff0088")) out.print("selected"); %>>玫红

          <option style="COLOR: #ff0000" value="#ff0000" <% if(fontcolor.equals("#ff0000")) out.print("selected"); %>>大红

          <option style="COLOR: #f4a460" value="#f4a460" <% if(fontcolor.equals("#f4a460")) out.print("selected"); %>>棕色

          <option style="COLOR: #888800" value="#888800" <% if(fontcolor.equals("#888800")) out.print("selected"); %>>卡其

          <option style="COLOR: #888888" value="#888888" <% if(fontcolor.equals("#888888")) out.print("selected"); %>>铁灰

          <option style="COLOR: #90e090" value="#90E090" <% if(fontcolor.equals("#90E090")) out.print("selected"); %>>绿色

          <option style="COLOR: #008800" value="#008800" <% if(fontcolor.equals("#008800")) out.print("selected"); %>>橄榄

          <option style="COLOR: #008888" value="#008888" <% if(fontcolor.equals("#008888")) out.print("selected"); %>>灰蓝

        </select>

        <input type="submit" name="Submit" value="发送" style="font-size:9pt" onClick="return checkForm();">

        <input type="button" name="logout" value="离开" style="font-size:9pt" onClick="return userLogout();">

        </td>

 <td>

              <table width="200" border="0" cellspacing="0" cellpadding="0" align="right"  bgcolor="#FF9900" >

                     <tr></tr>

<tr>

                     <td colspan="3" height="71" bgcolor="#B0D5F4" valign="middle" align="center">

                            <table width="91%" border="0" cellspacing="0" cellpadding="0">

                            <tr align="center" valign="middle">

                            </tr>

                            <tr align="center" valign="middle">

                            </tr>

                            </table>

                     </td>

                     </tr>

                     <tr>

                     <td colspan="3" height="10" bgcolor="#B0D5F4"><img src="../images/spacer.gif" width="1" height="10" alt=""></td>

                     </tr>

                     </table>

      </td>

    </tr>

  </table>

<%

String action2 = "";

int i = action.indexOf("B");

if (i != -1) {

       action = action.substring(0,i) + "<font color='blue'>" + talkwith + "</font>" + action.substring(i+1);

}

if(!action.equals("no")) {

       talkMessage = action + "<font color=" + fontcolor + ">" + talkMessage + "</font>";

       action2 = "yes";

}

else if (first != null) {

       talkMessage = "<font color = " + fontcolor + ">" + talkMessage + "</font>";

       action2 = "no";

}

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

if (online == null) {

       online = "";

}

if (online.equals("no")) {

       out.print("<script>alert(\"你已经被踢出,不要再捣乱啦!\");</script>");

       return;

}

if (Name == null) {

       return;

}

Vector  Message = null;

synchronized (application) {

       Message= (Vector)application.getAttribute("Message");

       if(Message==null) {

              Message= new Vector(30,10);

       }

       if(Message.size()>200) {

              Message.removeAllElements();

       }

       Message.addElement(aloneTalk);

       Message.addElement(Name);

       Message.addElement(talkwith);

       System.err.println("2"+talkwith);

       Message.addElement(talkMessage);

       Message.addElement(systemSpeak);

       Message.addElement(action2);

       application.setAttribute("Message", Message);

}

%>

</FORM>

</BODY>

</HTML>

运行结果:

输入语句对话框

6show.jsp

<html><head>

<script language="JavaScript" type="text/javascript">

function GetData(url)

{

        url="class_method.jsp?action=transcat.jsp";//调用页面

        try

        {

                DataLoad.src = url;

        }

        catch(e)

        {

        return false;

        }

        {

        var timeoutid = setTimeout("GetData()",2000)

        }

}

</script>

<script language="JavaScript" type="text/javascript" defer></script>

</head>

<body onLoad="javascript:GetData();">

<span id=loadContent>... ...</span>

</body>

</html>

7transact:

<HTML>

<HEAD>

<%@ page

language="java"

contentType="text/html; charset=GB2312"

pageEncoding="GB2312"

%>

<META http-equiv="Content-Type" content="text/html; charset=GB2312"><%@page import="java.util.*"%>

<META http-equiv="refresh" content="3">

<TITLE>outputMessage</TITLE>

</HEAD>

<script language="JavaScript" type="">

function scrollchange()

{

       parent.mainFrame.window.scroll(0,60000);

       parent.mainFrame.document.bgColor="#ffffff";

return true;

}

</script>

<BODY onLoad="scrollchange()" bgcolor="#B0D5F4">

<font color="#CC3333" size="+3" face="Times New Roman, Times, serif">Welcome to here!</font><br>

<img src="images/hello.gif"/>

<FORM method="post" action="show.jsp">

<%

String Name =(String)session.getAttribute("username");

if (Name == null) {

       return;

}

String str1="<div style='font-size:11pt;line-height:15pt'>";

String str2=new String("<font color='blue'>"+Name+"</font>");

String str3=new String("<font color='red'>[悄悄话]</font>");

String str4=new String("<br>");

String str5=new String("");

String str6="</div>";

Integer MessageIndex =(Integer)session.getAttribute("MessageIndex");

if((MessageIndex==null )||( MessageIndex.intValue() >= 200 ))

       MessageIndex=new Integer(0);

synchronized(application) {

       String alone=new String("yes");

       Vector DisplayMessage=null;

       DisplayMessage =(Vector)application.getAttribute("Message");

       if(DisplayMessage !=null) {

              if(DisplayMessage.size()< MessageIndex.intValue()) {

                     MessageIndex=new Integer(DisplayMessage.size());

              }

              if(MessageIndex.intValue()!= DisplayMessage.size()) {

                     for(int i=MessageIndex.intValue();i<DisplayMessage.size();i=i+6) {

                            int     aloneindex=i;

                            int     nameindex=i+1;

                            int     talkwithindex=i+2;

                            String  Messagestr= (String)DisplayMessage.get(i+3);

                            String  systemSpeak= (String)DisplayMessage.get(i+4);

                            String  action2= (String)DisplayMessage.get(i+5);

                            String  alonetag  = (String)DisplayMessage.get(aloneindex);

                            if(alonetag==null)

                                   alonetag=new String("all");

                            String  nametag =  (String)DisplayMessage.get(nameindex);

                            String talkwithtag =(String)DisplayMessage.get(talkwithindex);

                            System.err.println("1"+talkwithtag);

                            //设置欢迎语句

                            if(systemSpeak.compareTo("yes")==0) {

                                   Messagestr = str1+Messagestr+str6;

                                   %>

                                   <script language="JavaScript" type="">

                                          parent.mainFrame.document.write("<%= Messagestr%>")

                                   </script>

                                   <%

                            }

                            else {

                                   //悄悄话

                                   if(alonetag.compareTo(alone)==0) {

                                   //自己对别人说悄悄话

                                          if(nametag.compareTo(Name)==0) {

                                                 //有动作

                                                 if (action2.compareTo(alone)==0) {

                                                        Messagestr=str1+str3+str2+Messagestr+str4+str6;

                                                 }

                                                 //没动作

                                                 else {

                                                        Messagestr=str1+str3+str2+"<font color='blue'>"+talkwithtag+"</font>说:"+Messagestr+str4+str6;

                                                 }

%>

<script language="JavaScript" >

parent.mainFrame.document.write("<%= Messagestr%>")

</script>

<%

                                          }

                                          //别人对自己说悄悄话

                                          if((talkwithtag.compareTo(Name)==0)) {

                                                 //有动作

                                                 if (action2.compareTo(alone)==0) {

                                                        Messagestr=str1+str3+"<font color='blue'>"+nametag+"</font>"+Messagestr+str4+str6;

                                                 }

                                                 //没有动作

                                                 else {

                                                        Messagestr=str1+str3+"<font color='blue'>"+nametag+"</font>"+str2+"说:"+Messagestr+str4+str6;

                                                 }

                                                 %>

                                                 <script language="JavaScript">

                                                        parent.mainFrame.document.write("<%= Messagestr%>")

                                                 </script>

                                                 <%

                                          }

                                   }

                                   //自己对别人说话

                                   else {

                                          if(nametag.compareTo(Name)==0) {

                                                 //有动作

                                                 if (action2.compareTo(alone)==0) {

                                                        Messagestr=str1+str2+Messagestr+str4+str6;

                                                 }

                                                 //没动作

                                                 else {

                                                        Messagestr=str1+str2+"<font color='blue'>"+talkwithtag+"</font>说:"+Messagestr+str4+str6;

                                                 }

                                                 %>

                                                 <script language="JavaScript" type="">

                                                        parent.mainFrame.document.write("<%= Messagestr%>")

                                                 </script>

                                                 <%

                                          }

                                          //别人对自己说话

                                          else if((talkwithtag.compareTo(Name)==0)) {

                                                 //有动作

                                                 if (action2.compareTo(alone)==0) {

                                                        Messagestr=str1+"<font color='blue'>"+nametag+"</font>"+Messagestr+str4+str6;

                                                 }

                                                 //无动作

                                                 else {

                                                        Messagestr=str1+"<font color='blue'>"+nametag+"</font>"+str2+"说:"+Messagestr+str4+str6;

                                                 }

                                                 %>

                                                 <script language="JavaScript" type="">

                                                        parent.mainFrame.document.write("<%= Messagestr%>")

                                                 </script>

                                                 <%

                                          }

                                          //其他人的讲话

                                          else {

                                                 //有动作

                                                 if (action2.compareTo(alone)==0) {

                                                        Messagestr= str1+"<font color='blue'>"+nametag+"</font>"+Messagestr+str4+str6;

                                                 }

else {

         Messagestr= str1+"<font color='blue'>"+nametag+"</font>"+"<font color='blue'>"+talkwithtag+"</font>说:"+Messagestr+str4+str6;

                                                 }

                                                 %>

                                                 <script language="JavaScript" type="">

                                                        parent.mainFrame.document.write("<%= Messagestr%>")

                                                 </script>

                                                 <%

                                          }

                                   }

                            }

                            Integer count=new Integer(i+6);

                            session.setAttribute("MessageIndex",count);

                     }

              }

       }

       else

       out.println("Welcome to here!");

}

%>

</form>

</body>

</html>

8two

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>无标题文档</title>

</head>

<body>

<%

String username=request.getParameter("text1");

String password=request.getParameter("password1");

Class.forName("com.mysql.jdbc.Driver");

String url="jdbc:mysql://localhost/test";

String user="root";

String pas="111";

Connection conn=DriverManager.getConnection(url,user,pas);

String sql="select * from abu where username='"+username+"'";

Statement stmt=conn.createStatement();

ResultSet rs=stmt.executeQuery(sql);

if(rs.next())

{

out.print("<script language='javaScript'>");

out.print("alert('用户名');");

out.print("window.location.href='4.html'");

out.print("</script>");

}

else

{

stmt.executeUpdate("insert into abu(username,password) values('"+username+"','"+password+"')");

response.sendRedirect("login.jsp");

stmt.close();

conn.close();

}

%>

</body>

</html>

运行结果:

聊天界面

七、设计总结

本系统采取的测试方法是先进行各模块测试,经过修改和调整通过以后,进行总体的测试,测试结果各项功能均已经或基本达到了设计要求。

本网站采取的测试环境是:服务器采用WINDOWS XP操作系统+Tomcat信息服务管理器;客户机采用的是WINDOWS XP操作系统+IE浏览器。

     测试的主要内容包括:用户登录,用户注册,聊天者发言功能、聊天信息自动刷新功能,测试结果一切正常,达到了设计要求。

在本次网站设计实习过程中,老师严谨的治学精神和深厚的理论水平都使我收益匪浅。无论在理论上还是在实践中,都给予了我很大的帮助,使我得到很大的提高,这对于我以后的工作和学习都有很大的帮助。

更多相关推荐:
网站设计实训报告

宁波职业技术学院浙江宁波职业技术学院网页设计实训报告设计题目乐玩旅游班级网络3112班姓名凯赛尔阿巴斯学号指导老师电子信息工程系20xx1213乐玩旅游网站实训报告1实训目的1进一步熟悉和掌握网站建设的基本流程...

网页设计实习报告

20xx年5月世通华纳移动电视传媒集团有限公司正式成立是中国领先的移动电视传媒集团集团下设移动电视技术有限公司移动电视节目制作公司和移动电视广告公司三大核心部门通过在城市公交车高级写字楼商住楼等场所安装数字电视...

网页设计实践报告

中南大学本科生课程设计实践设计报告大学计算机基础题目学生姓名指导教师学院专业班级学生学号栀子花开xxxxxxxxx学院xx工程xxx班xxx计算机基础教学实验中心xx年xx月xx日1目录一任务内容3二设计的步骤...

网站设计实训报告

网站设计实训报告题目个人网站实训报告学号姓名指导老师院系专业实训时间一实训意义网页设计与制作综合实训是教学过程中重要的实践性教学环节它是根据专业教学计划的要求在教师的指导下对学生进行网页制作专业技能的训练培养学...

网页设计实习报告

扬州职业大学课程设计报告设计题目论沐乃衣时尚女装网站系别专业班级姓名学号指导教师完成时间13年6月24日目录1前言211课题意义212课题目的213课题研究范围214要解决的主要问题22网页开发技术321网页开...

关于网站建设的实习报告

防灾科技学院毕业实习报告题目关于网站建设的毕业实习报告系别专业学号学生姓名指导教师教务处制

网站制作实习报告

实习报告课程名称网页设计与制作专业班级11计算机网络技术姓名毛丽宏学号05实习时间信息工程系一实习目的1进一步熟悉和掌握网站建设的基本流程和技术规范2巩固运用Dreamweaver网页制作软件制作网页特别是制作...

计算机网站设计实习报告

软件学院毕业实习报告姓名专业班级学号实习地点实习内容实习时间报告写作时间洛阳理工学院软件学院毕业实习报告目录实习鉴定表11实习单位简介12实习时间13所从事的工作岗位24项目完成过程24111技术可行性3411...

思科网络设计实训报告

网络设计实训报告课题名称网络设计专业计算机网络技术班级网络G092学号27姓名指导教师20xx年12月27日目录网络设计实训报告0一课程设计目的1二课程设计题目描述1三课程设计报告内容231设计任务232设计要...

思科网络设计实训报告

网络设计实训报告课题名称网络设计专业计算机网络技术班级网络G092学号27姓名指导教师20xx年12月27日1目录网络设计实训报告1一课程设计目的3二课程设计题目描述3三课程设计报告内容431设计任务432设计...

动态网页设计实习报告

动态网页设计实习报告课程设计题目图书馆管理系统桂林理工大学信息科学与工程学院班级计算机083报告人姓名XX学号XXXXX承担角色辅助程序员同组组长XXXX实验指导教师陆秋实验地点教1楼1313机房完成起止日期2...

网页设计实习报告1

实习报告实习性质网页布局实务课程实习学生姓名黄小蝶专业班级指导教师邵亮刘铭实习时间20xx年12月29日20xx年1月2日实习地点1303重庆工程职业技术学院信息工程学院网页布局实务课程实习学生实习考核表目录1...

网站设计实习报告(31篇)