本人正在写一个聊天事的程序(现在还在主干的代码)但是EL表达式显示不出来内容,这是为什么啊??
这是wevlet的代码
package chat_system;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class login_chatServlet extends HttpServlet {
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
request.setCharacterEncoding("gb2312");
Structrue struct = new Structrue();
user_infoBean bean = new user_infoBean();
//接收用户信息
String username = request.getParameter("txtuser");
String pwd = request.getParameter("txtpwd");
//把用户信息写入bean
bean.setUser(username);
bean.setPwd(pwd);
try {
if (struct.check_login(bean)) {
//用于储存聊天室聊天记录的ArrayList
Object obj = getServletContext().getAttribute("arraychat");
if (obj == null) { //避免空指针约束
ArrayList arraychat = new ArrayList();
getServletContext().setAttribute("arraychat", arraychat);
obj = arraychat;
}
ArrayList array_chat = (ArrayList) obj;
//进入聊天室的时候再聊天室发出消息
array_chat.add("<font color='red'>大家热烈欢迎<b>" + username +
"<b>进入聊天室</font>");
getServletContext().setAttribute("arraychat", array_chat); //把聊天记录的ArrayList共享到内存里
//创建会话,使用于另自己的名字在link窗口变色
HttpSession ses = request.getSession();
ses.setAttribute("username", username);
//用于储存用户列表的ArrayList
Object obj1 = getServletContext().getAttribute("arraylist");
if (obj1 == null) { //避免空指针约束
ArrayList arraylist = new ArrayList();
ses.setAttribute("arraylist", arraylist);
obj1 = arraylist;
}
ArrayList array_list = (ArrayList) obj1;
array_list.add(username); //储存用户列表的ArrayList并共享到会话中
ses.setAttribute("arraylist", array_list);
response.sendRedirect("/webmo/chat_interface.jsp");
} else {
response.sendRedirect("/webmo/login_chat.jsp");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doGet(request, response);
}
//Clean up resources
public void destroy() {
}
}
这个是显示列表的代码
<%@page contentType="text/html; charset=GBK"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>chat_userlist</title>
<meta http-equiv="refresh" content="10"/>
</head>
<body bgcolor="#ffffff">
<font color="red">成员列表</font>
<table align="left" width="100%" height="100%">
<c:forEach var="userlist" items="${sessionScope.arraylist}">
<c:when test="${uesrlist}==${sessionScope.username}">
<tr valign="top">
<td>
<b>${userlist} </b>
</td>
</tr>
</c:when>
<c:when test="${uesrlist}!=${sessionScope.username}">
<tr valign="top">
<td>
<c:out value="${userlist}"/>
</td>
</tr>
</c:when>
</c:forEach>
</table>
</body>
</html>
各位版主赐教···!!!!!!!!!!
[此贴子已经被作者于2007-1-25 2:18:31编辑过]