index.jsp:
<form id="form1" name="form1" method="post" action="session.jsp"> <table width="500" border="0" height="54"> <tr> <td><div align="center">您的名字是:</div></td> <td><label> <input type="text" name="name" /> </div> </label></td> </tr> <tr> <td colspan="2"><label> <input type="submit" name="Submit" value="提交" /> </label></td> </tr> </table> <label></label> </form>
session.jsp:
<% String name=request.getParameter("name");//获取用户填写的用户名 session.setAttribute("name", name);//将用户名保存到session对象中 %> <form id="form1" name="form1" method="post" action="MyJsp.jsp"> <table width="500" border="0"> <tr> <td>您的名字是:</td> <td><form id="form3" name="form3" method="post"> <label> <td> <%=name %></td> </label> </form> </td> </tr> <tr> <td><div align="center">您的想要去的地方是:</div></td> <td><label> <input type="text" name="address" /> </div> </label></td> </tr> <tr> <td colspan="2"><label> <input type="submit" name="Submit" value="提交" /> </label></td> </tr> </table> <label></label> </form>
MyJsp.jsp:
<% String name=session.getAttribute("name").toString(); String address=request.getParameter("address"); %> <form id="form1" name="form1" method="post" action=""> <table width="500" border="0"> <tr> <td colspan="2"><div align="center">SHOW</div></td> </tr> <tr> <td>你的名字是:</td> <td><%=name %></td> <tr> <td><div align="center">您的想要去的地方是:</div></td> <td><%=address %></td> </tr> </table> </form>
时间: 2024-11-03 05:42:39