📄 input.jsp
字号:
<%@page contentType="text/html;charset=gb2312"%>
<%@page language="java" import="java.util.*" %>
<html>
<head>
<script language="JavaScript">
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";
}
</script>
</head>
<body bgcolor="#FF9900" topmargin="10">
<form name="chatForm" method="post">
<table border="0" width="100%" align="center" cellspacing="0" cellpadding="0">
<tr valign="top"><td>
<%
String first = (String)request.getParameter("first");
String talkMessage=(String)request.getParameter("usermessage");
if(talkMessage!=null)
talkMessage=new String(talkMessage.getBytes("8859_1"));
String talkwith =(String)request.getParameter("talkwith");
if(talkwith!= null)
talkwith=new String(talkwith.getBytes("8859_1"));
String systemSpeak=(String)request.getParameter("systemSpeak");
String chatName=(String)session.getAttribute("chatName");
out.println("【<font color='#0000ff'>"+chatName+"</font>】"+"对");
//用户第一次进入,初始化状态
if(first==null)
{
talkMessage="系统公告:"+chatName+"进入了聊天室,大家欢迎!";
systemSpeak = "yes";
}
if(talkwith==null)
{
talkwith="所有人";
}
%>
<input type="text" name="talkwith" value= <%= talkwith %> size="8" style="font-size:9pt">
<input type="hidden" name="first" value="first">
<input type="hidden" name="systemSpeak" value="no">
<input type="text" name="usermessage" size=50 style="font-size:9pt">
<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();">
<%
if(chatName==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(chatName);
Message.addElement(talkwith);
Message.addElement(talkMessage);
Message.addElement(systemSpeak);
application.setAttribute("Message", Message);
}
%>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -