前院女生吧 关注:9贴子:2,077
  • 0回复贴,共1

【前院女生】 java

只看楼主收藏回复

ChatRoom.jsp

<%@page import="java.util.*"%> 
<form method=post action="say.jsp"> 
 <input type="text" name="say">  
 <input type="submit" value="提交">  
 <input type="reset" value="重置"> 
</form> 
<hr /> 
<% 
ArrayList al_say=new ArrayList(); 
if(application.getAttribute("say") != null)
{al_say=(ArrayList)application.getAttribute("say"); 
for (int says=0;says<al_say.size();says++) 

 %> 
 <%=al_say.get(says)%><br><% 

}
%>
 
index.jsp

<%@page import="java.util.*"%> 
<% 
ArrayList al_say=new ArrayList(); 
application.setAttribute("say",al_say); 
response.sendRedirect("ChatRoom.jsp");
%>

say.jsp

<%@page import="java.util.*"%> 
<% 
String say=new String (request.getParameter("say").getBytes("GB2312")); 
ArrayList al_say=new ArrayList(); 
al_say=(ArrayList)application.getAttribute("say"); 
al_say.add(say); 

response.sendRedirect("ChatRoom.jsp"); 

%>



1楼2007-11-01 10:54回复