<H3> <P>修改密码,密码长度不能超过30个字符: paper51.com
<%String str=response.encodeURL("modifyPassword.jsp"); 内容来自www.paper51.com %> http://www.paper51.com <H3> 内容来自论文无忧网 www.paper51.com <FORM action="<%=str%>"Method="post"> 内容来自论文无忧网 www.paper51.com
<BR>输入您的用户名: http://www.paper51.com <BR><Input type=text name="logname" value="<%=login.getLogname()%>" > copyright paper51.com <BR>输入您的密码: 内容来自论文无忧网 www.paper51.com
<BR><Input type=password name="password"> 内容来自论文无忧网 www.paper51.com <BR>输入您的新的密码: copyright paper51.com <BR><Input type=text name="newPassword1"> http://www.paper51.com
<BR>请再输入一次新密码: copyright paper51.com
<BR><Input type=text name="newPassword2"> http://www.paper51.com
<BR><Input type=submit name="g" value="提交"> 内容来自www.paper51.com </FORM> http://www.paper51.com <%!//处理字符串的一个常用方法: paper51.com
publicString getString(String s) paper51.com { if(s==null) s=""; 内容来自论文无忧网 www.paper51.com
try {byte a[]=s.getBytes("ISO-8859-1"); http://www.paper51.com s=new String(a); copyright paper51.com } 内容来自www.paper51.com catch(Exception e) 内容来自www.paper51.com { } copyright paper51.com return s; 内容来自论文无忧网 www.paper51.com } copyright paper51.com %> 内容来自www.paper51.com <% paper51.com Stringlogname=request.getParameter("logname"); //获取提交的用户名。 内容来自论文无忧网 www.paper51.com
logname=getString(logname); 内容来自论文无忧网 www.paper51.com Stringpassword=request.getParameter("password"); //获取提交的密码。 http://www.paper51.com password=getString(password); 内容来自www.paper51.com StringnewPassword1=request.getParameter("newPassword1"); //获取提交的新密码1。 copyright paper51.com newPassword1=getString(newPassword1); 内容来自论文无忧网 www.paper51.com StringnewPassword2=request.getParameter("newPassword2"); //获取提交的新密码2。 内容来自论文无忧网 www.paper51.com newPassword2=getString(newPassword2); paper51.com try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); copyright paper51.com } http://www.paper51.com
catch(ClassNotFoundException event){} copyright paper51.com //验证身份: copyright paper51.com
Connectioncon=null; paper51.com Statementsql=null; 内容来自www.paper51.com booleanmodify=false; http://www.paper51.com
booleanifEquals=false; http://www.paper51.com ifEquals=(newPassword1.equals(newPassword2))&&(newPassword1.length()<=30); copyright paper51.com if(ifEquals==true) copyright paper51.com { try{con=DriverManager.getConnection("jdbc:odbc:shop","",""); 内容来自论文无忧网 www.paper51.com sql=con.createStatement(); 内容来自论文无忧网 www.paper51.com boolean bo1=logname.equals(login.getLogname()), copyright paper51.com bo2=password.equals(login.getPassword()); copyright paper51.com if(bo1&&bo2) http://www.paper51.com {//修改密码: http://www.paper51.com
modify=true; paper51.com out.print("您的密码已经更新"); copyright paper51.com
String c="UPDATE user SET password ="+"'"+newPassword1+"'"+ copyright paper51.com " WHERE logname = "+"'"+logname+"'"; paper51.com sql.executeUpdate(c); 内容来自论文无忧网 www.paper51.com
} 内容来自论文无忧网 www.paper51.com
con.close(); 内容来自www.paper51.com
} copyright paper51.com
catch(SQLException e1) {} 内容来自论文无忧网 www.paper51.com } copyright paper51.com else paper51.com
{ out.print("你两次输入的密码不一致或长度过大"); 内容来自论文无忧网 www.paper51.com } 内容来自论文无忧网 www.paper51.com if(modify==false&&ifEquals==true) paper51.com { out.print("<BR>您没有输入密码帐号或<BR>您输入的帐号或密码不正确"+logname+":"+password); paper51.com } 内容来自www.paper51.com %> http://www.paper51.com (4)商品浏览 showBookList.jsp: 内容来自论文无忧网 www.paper51.com <P> 商品目录: copyright paper51.com <%! //声明一个共享的连接对象: 内容来自论文无忧网 www.paper51.com Connectioncon=null; copyright paper51.com //显示数据库记录的方法: http://www.paper51.com
publicvoid showList(ResultSet rs,javax.servlet.jsp.JspWriter out,int n,String buybook) copyright paper51.com {try paper51.com
{ copyright paper51.com
http://www.paper51.com |