showmsg.jsp

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

JSP
58
字号
<html>
<meta http-equiv="refresh" content="10">
<head>
<title>聊天室聊天信息列表</title>
</head>
<%@ page contentType="text/html;charset=gb2312" %>
<%@  page import="java.util.Vector" %>
<body bgcolor="#FFFFCC" >
<%
String tempmsg;
String cUserName=(String)session.getAttribute("username");
Vector chatMsg=(Vector)getServletContext().getAttribute("chatMsg");
for (int i=0;i<chatMsg.size();i++)
{
	String s_UserName;
	String o_UserName;
	int firstPos;
	int lastPos;
	boolean ifwhisper=false;
	
	tempmsg=chatMsg.elementAt(chatMsg.size()-i-1).toString();
	if (tempmsg.startsWith("#"))
	{
		ifwhisper=true;
	}
	if (ifwhisper)
	{
		firstPos=1;
		lastPos=tempmsg.indexOf("#",firstPos);
		s_UserName=tempmsg.substring(firstPos,lastPos);
			
		firstPos=lastPos+1;
		lastPos=tempmsg.indexOf("#",firstPos);
		o_UserName=tempmsg.substring(firstPos,lastPos);
				
		firstPos=lastPos+1;
		tempmsg=tempmsg.substring(firstPos,tempmsg.length());
		if(o_UserName.equals(cUserName))
		{
			tempmsg="<img src='new.gif'>"+tempmsg;
			out.println(tempmsg);
		}
		if (s_UserName.equals(cUserName))
		{
			tempmsg="<img src='new.gif'>"+tempmsg;
			out.println(tempmsg);
		}
	}
	else
	{
		out.println(tempmsg+"<br>");
	}

}
%> 
</body>
</html>

⌨️ 快捷键说明

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