复件 login.jsp
上传用户:sanhemotor
上传日期:2010-01-25
资源大小:381k
文件大小:1k
源码类别:

电子政务应用

开发平台:

Java

  1. <%@ page session="true" %>
  2. <%@ page import="java.sql.* " %>
  3. <html>
  4. <head>
  5. <title>Book store</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
  7. <body bgcolor="#F4F5FF">
  8. <font face="Times New Roman,Time" size="+3"> 网上书店 </font> 
  9. <hr><p><center>
  10. <%
  11.   String name=request.getParameter("name");
  12.   String pwd=request.getParameter("password");
  13.  
  14. try
  15. {String  sDBDriver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
  16.       Class.forName(sDBDriver);
  17.  String sConnStr="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Web";
  18. String username="sa";
  19. String password="";
  20. Connection connWeb=DriverManager.getConnection(sConnStr,username,password);
  21. Statement stmt=connWeb.createStatement(); 
  22. String query="select Customer_ID from customer_info where Name='"+name+"' and Passwd='"+pwd+"'";
  23. ResultSet res=stmt.executeQuery(query);
  24. if(res.next())
  25. {
  26. Integer temp=new Integer(res.getInt(1));
  27. res.close();
  28. String customerid=temp.toString();
  29. session.putValue("loginSign","OK");
  30. session.putValue("cID",customerid);
  31. %>
  32. <jsp:forward page="list.jsp"/>
  33. <%
  34. }
  35. else
  36. {
  37. res.close();
  38. session.putValue("login_message","用户名或密码错误");
  39. %>
  40. <jsp:forward page="register.jsp"/>
  41. <%
  42. }
  43. }
  44. catch(Exception e)
  45. {
  46. e.getMessage();
  47. }
  48. %>
  49. </center>
  50. </body>
  51. </html>