编写jsp将用户注册信息保存在application中
1、注册页面代码
<%@ 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="baocun.jsp" method="post"> <table> <tr><td> 帐号:<input type="text" name="name"><br> 密码:<input type="password" name="password"><br> <br><input type="submit" value="确认注册"> </td></tr> </table> </form> </body> </html>
2、将信息存入application代码
<%@ 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.setAttribute("name",request.getParameter("name")); application.setAttribute("password",request.getParameter("password")); %> application接收到提交内容! </body> </html>
3、运行结果