jsp留言session
Posted 鱼在我这里
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jsp留言session相关的知识,希望对你有一定的参考价值。
简单的留言板显示
<%@ 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>留言板</title> </head> <body> <form action="session0625.jsp" method="post" id="form1" name="form1"> <div align="center"> <table width="50%" border="0"> <tr > <td width="10%">您的联系邮箱:</td> <td width="40%"><input type="text" name="email"/></td> </tr> </table> <table width="50%" border="0" height="40%"> <tr><td>留言内容:</td></tr> <tr><td><input type="text" style="width: 50%;height: 100%" name="liuyan"/></td></tr> <tr><td><input type="submit" value="提交"/></td></tr> </table> </div> </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>留言板session</title> </head> <body> <% String email=new String(request.getParameter("email").getBytes("ISO-8859-1"),"UTF-8"); session.setAttribute("email",email); String liuyan=new String(request.getParameter("liuyan").getBytes("ISO-8859-1"),"UTF-8"); session.setAttribute("liuyan",liuyan); %> <form action="result0625.jsp" method="post"> <table> <tr><td>确定显示留言内容?</td></tr> <tr> <td><input type="submit" value="确定"/></td> <td><input type="reset" value="取消"/></td> </tr> </table> </form> <%-- 您的邮箱地址是: <%=email %> <br> 您的留言内容是: <%=liuyan %> --%> </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 email=(String)session.getAttribute("email"); String liuyan=(String)session.getAttribute("liuyan"); %> 您的邮箱地址是: <%=email %> <br> 您的留言内容是: <%=liuyan %> </body> </html>
运行结果:
以上是关于jsp留言session的主要内容,如果未能解决你的问题,请参考以下文章