网页传值问题解决
1.jsp
<form method="get" action="2.jsp"> what's your name <input type="text" name="username"> <input type="submit" value="submit"> </form>
2.jsp
<form method="post" action="3.jsp"> <%String name=request.getParameter("username"); session.setAttribute("username",name); %> Your name is: <%=request.getParameter("username")%> <br>what's your hobby <input type=text name=hobby> <input type=submit value=submit> </form>
3.jsp
your name is:<%=session.getAttribute("username")%> <br> your hobby is:<%=request.getParameter("hobby")%> <br> </form>
session存储周期长,不安全
request存储周期短,安全