一个简单的JSP登陆代码

 
源代码
  
一个简单的JSP登陆代码
08.7.12

<%@ page contentType="text/html; charset=GBK" %> <jsp:useBean id="Dl" scope="request" class="dlxx.Dl" />   <%@ page import="java.sql.*" %> <%@ page import="sun.jdbc.rowset.*;" %> <%request.setCharacterEncoding("GBK");%> <%//得到隐藏域的值 String doCreate = request.getParameter("doCreate"); String uname = request.getParameter("uname"); String psw = request.getParameter("psw"); if (doCreate==null){doCreate="false";} //这说明提交过来了数据 if (doCreate.equals("true")) { //执行增加操作,要判断主键是否重复-1,     CachedRowSet resultPage=null;     resultPage=Dl.getRowSet("select * from dl where    uname='"+uname+"'");     if (resultPage.next()){        resultPage=Dl.getRowSet("select * from dl where    uname='"+uname+"' and psw='"+psw+"'");     if (resultPage.next()){      //登陆成功处理      String tname=resultPage.getString("tname");      session.setAttribute("tname", tname);      session.setAttribute("uname", uname);     response.sendRedirect("index.htm");     return;     }       }       %> <script language="javascript">        alert("用户名或者密码错误!"); history.back();   </script>   <%   

    }     %>

<html> <head> <title>系统页面登陆</title> <META http-equiv=Content-Type content="text/html; charset=GBK"> <script language="JavaScript"    src="calendar.js"></Script>     <link href="images/server.css" rel="stylesheet" type="text/css">       <style type="text/css"> <!--   body,td,th { font-size: 12px;} a {font-size: 12px;} .input_1 {     BORDER-RIGHT: #c7c8c7 1px solid; BACKGROUND-POSITION: 50% top; BORDER-TOP: #c7c8c7 1px solid; FONT-SIZE: 12px; BACKGROUND-IMAGE: url(images/inputshow.gif); BORDER-LEFT: #c7c8c7 1px solid; COLOR: #7b7b7b; BORDER-BOTTOM: #c7c8c7 1px solid; BACKGROUND-REPEAT: repeat-x; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif } .style1 {color: #000000}     -->     </style>    <script language="javascript">   function checkInput() { if (document.dlym.uname.value==""){      alert("请输入用户名!");      document.dlym.uname.focus();      return false;}      if (document.dlym.psw.value==""){      alert("请输入密码!");      document.dlym.psw.focus();      return false;}     return true; } </script> </head> <body background="images/index_17.gif" leftmargin="000" topmargin="0"> <form    name="dlym" method="POST" action="dlym.jsp" onSubmit="return checkInput();" >     <table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/TYPE_BG.gif">       <tr> <td    height=26></td></tr>     </table> <br>            <table    align="center" border="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#D6E6F0" cellpadding="6">              <tr><td colspan="2"    background="IMAGES/bac.gif"><div align="center"><b> 登陆信息</b></div></td> </tr> <tr>         <td width="69">用户名:</td>      <td width="124">   <input name="uname" type="text"     size="15" maxlength="15"> </td> </tr> <tr>         <td>密码:</td>         <td width="124">   <input name="psw" type="password"     size="15" maxlength="15" > </td> </tr> <tr>              <td height="25" align="center" colspan="2" >        <input type="submit" value="确定" name="Submit" >       <input type="hidden" name="doCreate" value="true">       <input type="reset" value="取消" name="Submit2">            </td></tr>           </table>        <br></td></tr>      </table> </form>   </html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值