Jsp简易留言板的实现:application与Arraylist应用示例

来源:互联网 发布:处方软件 编辑:程序博客网 时间:2024/06/05 05:07
<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><u>index.jsp</u></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>< import="java.util.*"%></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><html xmlns="<a target=_blank href="http://www.w3.org/1999/xhtml" style="color: rgb(240, 109, 153);">http://www.w3.org/1999/xhtml</a>"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>index</title></head></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><body><% ArrayList al_say=new ArrayList(); application.setAttribute("say",al_say); response.sendRedirect("ChatRoom.jsp"); %> </body></html></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><u>ChatRoom.jsp</u></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>< import="java.util.*"%></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><html xmlns="<a target=_blank href="http://www.w3.org/1999/xhtml" style="color: rgb(240, 109, 153);">http://www.w3.org/1999/xhtml</a>"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>ChatRoom</title></head></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><body><form method=post action="say.jsp">     <input type="text" name="say">     <input type="submit" value="提交">     <input type="reset" value="重置"> </form></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><% ArrayList al_say=new ArrayList(); al_say=(ArrayList)application.getAttribute("say"); for (int says=0;says<al_say.size();says++){%>    <%=al_say.get(says)%><br/> <%}%> </body></html></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><u>say.jsp</u></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>< import="java.util.*"%></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><html xmlns="<a target=_blank href="http://www.w3.org/1999/xhtml" style="color: rgb(240, 109, 153);">http://www.w3.org/1999/xhtml</a>"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"/><title>无标题文档</title></head></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 14px;"><body><% String say=new String (request.getParameter("say").getBytes("iso-8859-1")); ArrayList al_say=new ArrayList(); al_say=(ArrayList)application.getAttribute("say"); al_say.add(say); response.sendRedirect("ChatRoom.jsp"); %> </body></html></p>
0 0
原创粉丝点击