Pass the JSP page value, and pass the jsp page
Use session to pass values and redirect the page
// Obtain the value String name = request submitted by the user. getParameter ("username"); String pwd = request. getParameter ("password"); // create HttpSessio object HttpSession s = request. getSession (); // bind the value to s. setAttribute ("Sname", name); s. setAttribute ("Spwd", pwd); // redirect response. sendRedirect ("yinyu. jsp ");
Obtain the value on the yinyu. jsp page.
// Use the session Value
String username = (String) session. getAttribute ("Sname"); String password = (String) session. getAttribute ("Spwd ");
Or
${Sname}; ${Spwd};
Use the request Method to pass the value and redirect the page
// Obtain the value String name = request submitted by the user. getParameter ("username"); String pwd = request. getParameter ("password"); // bind the value to the request. setAttribute ("Rname", name); request. setAttribute ("Rpwd", pwd); // redirect RequestDispatcher rd = request. getRequestDispatcher ("yinyu. jsp "); rd. forward (request, response );
Obtain the value on the yinyu. jsp page.
// Use the value of request assistance
String username = (String) request. getAttribute ("Rname"); String password = (String) request. getAttribute ("Rpwd ");
Or
$ {Sname };
${Spwd};
| SetAttribute () |
SetAttribute ("custom name", reference to bind ); |
| GetAttribute () |
Get the property value getAttribute ("custom name in setAttribute "); |
| SendRedirect () |
Redirect to sendRedirect ("the address of the page to jump "); |