一个简单的使用JSP技术开发的在线聊天室

源代码在线查看: transact.jsp

软件大小: 458 K
上传用户: Rebecca_SYF
关键词: JSP 技术开发
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
								language="java"
				contentType="text/html; charset=GB2312"
				pageEncoding="GB2312"
				%>
				
				
				outputMessage
				
				
				
				function scrollchange()
				{
					parent.mainFrame.window.scroll(0,60000);
					parent.mainFrame.document.bgColor="#ffffff";
				return true;
				}
				
				
				
				
				
				
								String Name =(String)session.getAttribute("username");
				if (Name == null) {
					return;
				}
				String str1="";
				String str2=new String(""+Name+"");
				String str3=new String("[悄悄话]");
				String str4=new String("");
				String str5=new String("对");
				String str6="";
				
				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								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;
									%>
									
										parent.mainFrame.document.write("")
									
																	}
				
								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+"对"+talkwithtag+"说:"+Messagestr+str4+str6;
											}
											%>
											
												parent.mainFrame.document.write("")
											
																					}
										//别人对自己说悄悄话
										if((talkwithtag.compareTo(Name)==0)) {
											//有动作
											if (action2.compareTo(alone)==0) {
												Messagestr=str1+str3+""+nametag+""+Messagestr+str4+str6;
											}
											//没有动作
											else {
												Messagestr=str1+str3+""+nametag+"对"+str2+"说:"+Messagestr+str4+str6;
											}
											%>
											
												parent.mainFrame.document.write("")
											
																					}
				
									}
									//自己对别人说话
									else {
										if(nametag.compareTo(Name)==0) {
											//有动作
											if (action2.compareTo(alone)==0) {
												Messagestr=str1+str2+Messagestr+str4+str6;
											}
											//没动作
											else {
												Messagestr=str1+str2+"对"+talkwithtag+"说:"+Messagestr+str4+str6;
											}
											%>
											
												parent.mainFrame.document.write("")
											
															
										}
										//别人对自己说话
										else if((talkwithtag.compareTo(Name)==0)) {
											//有动作
											if (action2.compareTo(alone)==0) {
												Messagestr=str1+""+nametag+""+Messagestr+str4+str6;
											}
											//无动作
											else {
												Messagestr=str1+""+nametag+"对"+str2+"说:"+Messagestr+str4+str6;
											}
											%>
											
												parent.mainFrame.document.write("")
											
																					}
										//其他人的讲话
										else {
											//有动作
											if (action2.compareTo(alone)==0) {
												Messagestr= str1+""+nametag+""+Messagestr+str4+str6;
											}
											else {
												Messagestr= str1+""+nametag+""+"对"+talkwithtag+"说:"+Messagestr+str4+str6;
											}
											%>
											
												parent.mainFrame.document.write("")
											
																					}
				
									}
								}
				
								Integer count=new Integer(i+6);
				
								session.setAttribute("MessageIndex",count);
				
							}
						}
					}
					else
					out.println("Welcome to here!");
				}
				
				%>
				
				
				
				
				
							

相关资源