login.jsp
上传用户:sxlinghang
上传日期:2022-07-20
资源大小:1405k
文件大小:2k
源码类别:

数据库编程

开发平台:

Java

  1. <%@ page session="true" %>
  2. <jsp:useBean id="login" scope="page" class="bookshop.run.login" />
  3. <%
  4. String mesg = "";
  5. if( request.getParameter("username")!=null && !request.getParameter("username").equals("")){
  6. String username =request.getParameter("username");
  7. String passwd = request.getParameter("passwd");
  8. username = new String(username.getBytes("ISO8859-1"));
  9. passwd = new String(passwd.getBytes("ISO8859-1"));
  10. login.setUsername(username);
  11. login.setPasswd(passwd);
  12. out.print(username+passwd);
  13. if (login.excute()){
  14. session.setAttribute("username",username);
  15. String userid = Long.toString(login.getUserid());
  16. session.setAttribute("userid",userid);
  17. response.sendRedirect("booklist.jsp");
  18. %>
  19. <%
  20. }else {
  21. mesg = "登录出错!" ;
  22. }
  23. }
  24. %>
  25. <%@include file="/bookshop/inc/head.inc"%>
  26. <script language="javascript">
  27.  function checkform() {
  28. if (document.form1.username.value=="" || document.form1.passwd.value==""){
  29. alert("用户名或密码为空!");
  30. return false;
  31. }
  32. return true;
  33.   }
  34. </script>
  35. <div align=center>用户登录 </div>
  36.           <br>          
  37. <% if (!mesg.equals("")){
  38. out.println("<p>" + mesg + "</p>");}%>
  39.   <form name="form1" method="post" action="login.jsp">
  40.     <table width="400" border="0" cellspacing="1" cellpadding="1" align="center">
  41.     <tr> 
  42.       <td width="147" align="right">用户名:<br>
  43.       </td>
  44.       <td width="246" valign="top">
  45.           <input type="text" name="username" size="16" maxlength="25">
  46.         </td>
  47.     </tr>
  48.     <tr> 
  49.       <td width="147" align="right">密码:</td>
  50.       <td width="246" valign="top">
  51.           <input type="password" name="passwd" maxlength="20" size="16">
  52.         </td>
  53.     </tr>
  54.     <tr> 
  55.       <td width="147" align="right">&nbsp;</td>
  56.       <td width="246" valign="top">
  57.           <input type="submit" name="Submit" value="登录" onclick="javascript:return(checkform());">
  58.           <input type="reset" name="Submit2" value="取消">
  59.         </td>
  60.     </tr>
  61.     <tr>     
  62.       <td colspan="2" align="center">
  63.         <p>&nbsp;</p>
  64.         测试用户:wxy 密码:wxy
  65.       </td>
  66.     </tr>
  67.     <tr> 
  68.     
  69.       <td colspan="2" align="center">
  70.         <p>&nbsp;</p>
  71.         <p>如果你还不是本站用户,请在此<a href="reg.jsp">注册</a></p>
  72.       </td>
  73.     </tr>
  74.   </table>
  75.     </form>
  76.  <%@include file="/bookshop/inc/tail.inc"%>