⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 send.jsp

📁 JSP 网络聊天 源代码
💻 JSP
字号:
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.*" %>
<HTML>
<HEAD>
<TITLE> 发送消息 </TITLE>
<META NAME="Author" CONTENT="jj">
</HEAD>
<% int  wordslen =0;
   String linewords="";

   Vector chatwords = (Vector) application.getAttribute("chatwords");
   String fontcolor= request.getParameter("fontcolor");
   String photo=request.getParameter("photo");
   String face=(String) session.getValue("Face");  //获取用户发送信息的个部分

   if (fontcolor==null) {fontcolor="black";}
   if (face==null) {face="0";};
   if (photo==null){photo="0";}; //置默认信息

   if (chatwords==null) {     // 创建聊天信息列表
	   chatwords = new Vector();
	   application.setAttribute("chatwords",chatwords);
      } else {    //以下完成各部分的拼接得到完整的发送信息
	 	 String user1 =request.getParameter("user");
	     if (user1==null) {;}   
	     String words = request.getParameter("words");
	     if  (words!=null) wordslen = words.length();
	     if  (wordslen >0)  {
		   String act = request.getParameter("act");
	       String talkto = request.getParameter("talkto");
           int i = act.indexOf("B");
	       if (i != -1) {
	          act = act.substring(0,i) + "<B><U>" + talkto + " </U></B>" + act.substring(i+1);
           }
           if (!photo.equals("0")) { 
			      linewords="<p><font size =3 ><B>"+user1+"   </B></font><IMG SRC=images/face"+face +".gif WIDTH=25 HEIGHT=25 BORDER=1 >  " + act +"<FONT  COLOR="+fontcolor+"  >" +words+" </FONT>"+"  <IMG SRC=images/"+photo+".gif  WIDTH='16' HEIGHT='16' BORDER=0  >" ;}
		   else  {
			  linewords= "<p><font size =3 ><B><I>"+user1+"   <IMG SRC=images/face"+face+".gif WIDTH=25 HEIGHT=25 BORDER=1 ></I></B></font>  " + act +"<FONT  COLOR="+fontcolor+" >"+words+"</FONT>";
				}
		   byte[] temp = linewords.getBytes("iso8859-1");
	       linewords= new String(temp);
		   chatwords.add(linewords);  //发送信息存入信息列表
	   }
   }
 %>
<BODY bgcolor=#99CCFF >
<BR>  
<TABLE border=0 cellspacing=0 cellpadding=0 >
<FORM action="#" method=get name="inputform"  >
<TBODY><TR><TD colspan="3">
<INPUT type="hidden" name="user" value="<%= (String)session.getValue("userid")%> ">
<FONT SIZE="2" >对象</FONT>
<INPUT name="talkto" value="所有人" size="8"  
readonly tabindex=5>

<SELECT name="act" onchange="words.focus();" tabindex=4>
	<option value='向B说道:' selected>说话</option>
	<option value='很严肃的问道B:'>请问</option>
	<option value='使劲地拍着巴掌向B喊:'>喝采</option>
	<OPTION VALUE="抿着嘴向着B:">微笑</OPTION>
	<OPTION VALUE="扭过头跟B说:">躲避</OPTION>
</SELECT><SELECT name="fontcolor"  onchange="words.focus();" tabindex=3>
	<option value="black" STYLE="COLOR: "<%if (fontcolor.equals("black")) out.print("selected");%> >颜  色</option>
	<option style="BACKGROUND: #550088" value="#550088" <%if (fontcolor.equals("#550088")) out.print("selected");%>></option>
	<option style="BACKGROUND: #55001f" value="#55001f" <%if (fontcolor.equals("#55001f")) out.print("selected");%>></option>
	
</SELECT>
<SELECT name="photo" onchange="words.focus(); PerformSubmit('fdf');">
	<option value="0" selected>贴图</option>
	<OPTION VALUE="1">微笑</OPTION>
	<OPTION VALUE="3">大笑</OPTION>
	<OPTION VALUE="4">爆笑</OPTION>
	<OPTION VALUE="2">甜笑</OPTION>
	</SELECT>
</TD></TR>
<TR><TD colspan="3">
<FONT SIZE="2" >信息</FONT>
<INPUT name="words" size="45" maxlength="120" tabindex=1 value="">
<INPUT type="submit" value="发 送" name="submit1" class="btnStyle"  tabindex=10>
<span class="p9">
		<a href="exit.jsp" target='_top'>
		<IMG SRC="images/leave.gif" WIDTH="60" HEIGHT="35" BORDER=0 ALT="">
		</a></span>
     </TD>
    </TR></TBODY></FORM></TABLE>
	</BODY>
</HTML>

⌨️ 快捷键说明

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