<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form action="messagePane2.jsp" method="post" name="form"> 输入名字:<input type="text" name="name"><br> 输入内容:<textarea name="messages" ></textarea><br> <input type="submit" value="提交信息" name="submit"> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% String name=new String (request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8"); String messages=new String(request.getParameter("messages").getBytes("ISO-8859-1"),"UTF-8"); String s="姓名:"+name+"<br>"+"内容:"+messages+"<br>"; String str=(String)application.getAttribute("message"); if(str==null) { application.setAttribute("message",s); } else { str+=s; application.setAttribute("message",str); } out.print("您的信息已经提交!"); %> <a href="news.jsp">查看留言</a> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% // application.removeAttribute("message"); String s=(String)application.getAttribute("message"); out.print(s); %> <a href="lianxi.jsp">继续留言</a> </body> </html>