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

📄 jsp2.jsp

📁 一个JSP做的聊天室,有点丑,不过要以学习一下
💻 JSP
📖 第 1 页 / 共 2 页
字号:
      </td>
      <td width="13%" height="42"> 
        <div align="right"><a href="../jsp5.jsp" target=hiddenFrame  onClick="alert(' 如果你开了私聊窗,将退出私聊窗口!')"><img src="images/go1.gif" width="100" height="20" border="0"></a></div>
      </td>
    </tr>
  </table>
  <table border="0" width="90%" align="center">
    <tr>
      <td width="10%">  <% 
    String testname=(String)request.getParameter("username");
     if(testname!=null)    
           {
	    session.putValue("name",testname);
	 
	    }
       else
             {
	     testname=(String)session.getValue("name");
	    
	     } 
          testname=new String(testname.getBytes("iso-8859-1"),"GBK");      
          out.println("["+testname+"]"+":");
      
 %> 
        <div align="right"></div>
      </td>
      <td width="90%"> 
        <input type="text" name="usermessage" size=50>
        <input type="SUBMIT" name="Submit" value="发送">
            <a href="../logout.jsp?logout=<%= new String("yes") %>" target="_top" onClick="return Logoutconfirm()"><img src="images/go.gif" width="78" height="20" border="0" align="middle"></a> 
      </td>
    </tr>
  </table>
  <table border="0" width="60%" align="center">
    <tr> 
      <td colspan="3" height="22"><%! String welcomestr="<font color=blue>各位好:我来了!!</font><br><font color=orage><b>[公告]来了一位新朋友,大家快欢迎! </b></font>";%><%! String TotalMessage; %><%  String str1col=new String("<font color=#cc9933><b>");
      String str2col=new String("<font color=#cc3366><b>");
      String str3col=new String("</b></font>");
      String  TotalMessage=null; 
      String  headstr=null;
    %><%  String  Name =(String)session.getValue("name");
    
     
      String  TalkWith=(String)request.getParameter("talkwith");               
              Withsen =(String)session.getValue("talkwith");
              if((TalkWith!=null)&&(!(Withsen.compareTo(TalkWith)==0)))
	        {		       
                  session.putValue("talkwith",TalkWith);      
		  }                    
           

 %><% 
     
     String  fontcolor=(String)request.getParameter("fontcolor");
     if(fontcolor==null)
        { fontcolor=new String("#000000");
	    session.putValue("fontcolor",fontcolor);
	    }
   	String col1=new String("colorstring");
     if(!(fontcolor.equals(col1)))
        session.putValue("fontcolor",fontcolor);

  String  fontstyle=(String)request.getParameter("fontstyle");
     if(fontstyle==null)
        { fontstyle=new String("span");
	    session.putValue("fontstyle",fontstyle);
	    }
   	String fontstyle2=new String("stylestring");
     if(!(fontstyle.equals(fontstyle2)))
        session.putValue("fontstyle",fontstyle);
	
    
    
      String  face=(String)request.getParameter("face"); 
      if(face==null)
      face=new String("facestring");
      face=new String(face.getBytes("iso-8859-1"),"GBK");
   

    
      String  TalkMessage=(String)request.getParameter("usermessage");
      if(TalkMessage==null)
      TalkMessage=welcomestr;
      else
       TalkMessage=new String(TalkMessage.getBytes("iso-8859-1"),"GBK");        
      
     
     String  action=(String)request.getParameter("action"); 
     if(action==null)
       action=new String("actionstring");
       action=new String(action.getBytes("iso-8859-1"),"GBK"); 
   
   %><%
   String actionstr1 = new String("actionstring");
   String str11=new String("ALL");
   String str12=new String("大家");
          str12=new String(action.getBytes("iso-8859-1"),"GBK"); 
   String str13=(String)session.getValue("alonetalk");
   String str14=new String("yes");
   
   String withstr11=(String)session.getValue("talkwith");
   if(Name.equals(withstr11))
 {
  out.println("<font color=red><b>提示信息:哦,怎么对自己说话 ? !</b></font>");
 }
   else if((withstr11.equals(str11)||withstr11.compareTo(str11)==0)&&str13.equals(str14)) 
  {
    out.println("<font color=red><b>提示信息:哈哈,你在对[大家]说悄悄话 ? !</b></font>"); 
  }
  else if((TalkMessage.length()==0)&&action.equals(actionstr1))     
{
  out.println("<font color=red><b>提示信息:朋友:请输入信息。谢谢!!!</b></font>"); 
 }
 
 else if(TalkMessage.equals(session.getValue("TalkMessage")))
   {
     out.println("<font color=red><b>提示信息:朋友:何必要说同样的话呢??</b></font>");
    }
 else if(TalkMessage.length()>100)
   {
     out.println("<font color=red><b>提示信息:朋友:太多了,我受不了,少一点吧!</b></font>");
    }
 else
  {  
      session.putValue("TalkMessage",TalkMessage);
       if(!(action.equals(actionstr1))&&!(TalkMessage.length()==0))
       {
          TalkMessage="<font color=blue><b>"+action+"</b></font>"+TalkMessage;
	}
	else if(!(action.equals(actionstr1)))
	{
	 TalkMessage="<font color=blue><b>"+action+"</b></font>";
	 }
      if( !(face.equals("facestring")) )
       {
        headstr=str2col.concat(face);   
        headstr=headstr.concat(str3col);
       }
     
       else
       {
        headstr=null;
        }
      
       fontstyle=(String)session.getValue("fontstyle");
	  if(fontstyle!=null)
       { 
         TalkMessage="<"+fontstyle+">"+TalkMessage+"</"+fontstyle+">";
        }

       fontcolor=(String)session.getValue("fontcolor");
       if(fontcolor!=null)
       {  String fontcolstr1=new String("<font color= ");
          String fontcolstr2=new String(">");
          String fontcolstr3=new String("</font>");
          String fontcolstr=fontcolstr1.concat(fontcolor);
                 fontcolstr=fontcolstr.concat(fontcolstr2);
                 TalkMessage=fontcolstr.concat(TalkMessage);
                 TalkMessage=TalkMessage.concat(fontcolstr3);
        }
      

       String s=new String("<font color=orage><b>说:</b> </font>");  
       TalkMessage=s.concat(TalkMessage);
       if(headstr!=null)
          TotalMessage=headstr.concat(TalkMessage); 
       else        
	 TotalMessage=TalkMessage;	
       if(TotalMessage==null)
       return;
      else{
        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(session.getValue("alonetalk")); 
            Message.addElement(session.getValue("name"));
            Message.addElement(session.getValue("talkwith"));
            Message.addElement(TotalMessage);
            application.setAttribute("Message", Message);  
	  
           } 
        }
      out.println("提示信息:");
   Integer count = null;
       count = (Integer) session.getValue("change");
    if (count == null)
        count = new Integer(0);
    count = new Integer(count.intValue() + 1);
    session.putValue("change", count);
 } %> <font color=blue>发送的信息条数:</font> <%= session.getValue("change")%> </td>
    </tr>
  </table>
</FORM>
   
</BODY>
</HTML>

⌨️ 快捷键说明

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