sendmsg_init.jsp

来自「jsp的技术教程」· JSP 代码 · 共 54 行

JSP
54
字号
<html>
<title>发送聊天信息</title>
<head>
<script language="JavaScript" type="text/javascript">
function  setCookie()
{
	document.cookie=form1.toTalk.selectedIndex+"#";
}
</script>
</head>

<%@ page import="java.util.Vector" %>
<%@ page contentType="text/html;charset=gb2312" %>

<body bgcolor="#CCCC99">
<!--当用户第一次说话后设置cookie并将本帧定位到sendmsg.jsp-->
<form action="sendmsg.jsp" method="post" onsubmit="setCookie()" id="form1">
   <table border="0" cellspacing="3" cellpadding="0">
    <tr>
	  <td><%=session.getValue("username")%></td>
      <td align="left" colspan="2"> 
              <input name="message" style="HEIGHT: 21px; WIDTH: 367px">
       </td>
    </tr>
    <tr>   
      <td align="center"> 
	  对象           
      </td>
	  <td align="left"> 
              <!--在一个下拉列表中显示所有用户名供用户选择-->
              <select name="toTalk">             
                <option value="all">全体在聊</option>
                <%
					Vector tempuser=(Vector)getServletContext().getAttribute("chatUser");
					for (int i=0;i<tempuser.size();i++)
					{
						out.println("<option>");
						out.println(tempuser.elementAt(tempuser.size()-i-1).toString());
						out.println("</option>");
					}

				%> 
              </select>
			  <input type="submit" value="说话呀" name="submit">
		</td>
		<td>
			   <a href="leavechat.jsp" target="_top">离开聊天室</a>
       </td>
    </tr>
  </table>
</form> 
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?