?? send_info.jsp
字號:
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@ page import="java.util.*" %>
<%
//獲取session中相應變量值
String isFirst = (String) session.getAttribute("First");
String sNickName = (String)session.getAttribute("NickName");
//獲取保存在application中的聊天信息
Vector vChat = (Vector) application.getAttribute("vChat");
//判斷聊天信息是否為空
if (vChat == null)
{
vChat = new Vector();
application.setAttribute("vChat",vChat);
//將用戶進入聊天室的消息加入聊天信息中
String sWel = "<font color=red>"+sNickName+"</font> 進入了聊天室!<br>";
vChat.add(sWel);
session.setAttribute("First","Not");
}
else
{
//判斷用戶是否是剛進入聊天室,如果是則將用戶進入聊天室的消息加入聊天信息中
if(isFirst == null)
{
String sWel = "<font color=red>"+sNickName+"</font> 進入了聊天室!<br>";
vChat.add(sWel);
session.setAttribute("First","Not");
}
else
{
//獲取聊天信息
String sContent = request.getParameter("Content");
String sTo = request.getParameter("To");
String sAction = request.getParameter("Action");
//判斷聊天內容是否為空,如果不為空就將聊天信息保存到Vector對象中
if(sContent != null && sContent != "")
{
//編碼轉換
sTo = new String(sTo.getBytes("iso8859_1"));
sAction = new String(sAction.getBytes("iso8859_1"));
sContent = new String(sContent.getBytes("iso8859_1"));
String sTotal = "<font color=blue>"+sNickName +"</font> "+ sAction + " 對 <font color=red>"+sTo +"</font> 說:"+ sContent +"<br>";
vChat.add(sTotal);
}
}
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>歡迎光臨風沙聊天室</TITLE>
<meta http-equiv="refresh" content="15">
</HEAD>
<BODY bgcolor="#DFFDFF">
<BR>
<form name="form1" action="send_info.jsp" method="post" target="_self">
<%=sNickName%>
<input type="text" name="Content" size="30" maxlength="50">
<input type="submit" name="sub" value="發言">
<a href="logout.jsp" target="_top">退出聊天室</a>
<br>
<br>
對
<select name="To">
<option value="所有人" selected>所有人</option>
<%
//獲取當前在線的用戶信息
Hashtable userList = (Hashtable) application.getAttribute("userList");
Enumeration e = userList.elements();
while(e.hasMoreElements())
{
String sInfo = (String) e.nextElement();
int i = sInfo.indexOf("***");
if(i != -1)
{
sInfo =sInfo.substring(i+3);
}
out.println("<option value=\""+sInfo+"\">"+sInfo+"</option>");
}
%>
</select>
動作表情
<select name="Action">
<option value="" selected>無表情</option>
<option value="微笑著">微笑</option>
<option value="臉紅紅地">臉紅</option>
<option value="惡狠狠地">兇惡</option>
<option value="依依不舍地">告別</option>
<option value="熱情地">打招呼</option>
</select>
</form>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -