⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.jsp

📁 jsp系统
💻 JSP
字号:
 <%@ page contentType="text/html; charset=GBK" %> 
  <jsp:useBean id="Xhxx" scope="request" class="dl.Xhxx" />  
 <%@ page import= "sun.jdbc.rowset.*;" %> 
 <%@ page import="java.sql.*" %> 
 <%request.setCharacterEncoding("GBK");
//定义 请求执行的程序执行后的结果 被服务器返回后在页面中的显示方式
%> 


 <%
 String doCreate = request.getParameter("doCreate"); //得到隐藏域的值 
 String uname = request.getParameter("uname");
  String pwd = request.getParameter("pwd");
 if (doCreate==null){doCreate="false";} 
 
 if (doCreate.equals("true")) //这说明提交过来了数据
 { 

  CachedRowSet resultPage=null;
  resultPage=Xhxx.getRowSet("select * from xhxx where  uname='"+uname+"'"); //发送请求:执行sql语句

  if (resultPage.next()){
     resultPage=Xhxx.getRowSet("select * from xhxx where  uname='"+uname+"' and pwd='"+pwd+"'"); //发送请求:执行sql语句
//如果执行sql语句得到一条记录将执行下面的判断中的程序
	 if (resultPage.next()){
	  //登陆成功处理
	  String tname=resultPage.getString("tname");
	  session.setAttribute("tname", tname);//建立会话获取服务器返回过来的字段的值
	  session.setAttribute("uname", uname);
	 response.sendRedirect("ok.jsp");//转到登陆成功页面
	 return;
	 }

    }
//如果执行sql语句后没有一条记录服务器将不会返回执行结果同时将执行下面的js程序
  %> 
 <script language="javascript">   
 	alert("用户名或者密码错误!"); //出错提示
	history.back();  //返回本页面
 </script> 
<%}%>
<html>
<head>
 <META http-equiv=Content-Type content="text/html; charset=GBK"> 
<title>用户登录</title>
<style type="text/css">
<!--
td {
	font-size: 12px;
}
-->
</style>
<link href="images/style.css" rel="stylesheet" type="text/css">
<script language = "javascript">
function check()
{
if (document.form1.uname.value==""){ 
 		alert("请输入用户名"); 
 		document.form1.uname.focus(); 
 		return false;} 
		if(document.form1.pwd.value==""){
                alert("请输入你的密码"); 
 		document.form1.pwd.focus(); 
 		return false;}  
		 return true; 
 } 
</script>
</head>

<body bgcolor="#0041de" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br>
<br>
<br>
<br>
<table width="688" height="421" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="bottom" background="images/denglu1.gif"> 
      <table width="438" height="211" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td align="center" valign="top">
		  <form name="form1" method="post" action="" onsubmit="return check();">
              <table width="285" height="46" border="0" cellpadding="0" cellspacing="0">
                <tr align="center"> 
                  <td width="140" height="21"><font color="#006699">用 &nbsp;户</font></td>
                  <td width="140"><font color="#006699">密&nbsp; 码</font></td>
                </tr>
                <tr align="center"> 
                  <td> 
                    <input name="uname" type="text" class="box" id="u1" size="17"></td>
                  <td> 
                    <input name="pwd" type="password" class="box" id="p1" size="17"></td>
                </tr>
              </table>
              <table width="248" height="35" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"> 
				  <input type="image" src="images/button.gif" width="234" height="35" name="submit" value="提交">
				  <input type="hidden" name="doCreate" value="true"></td>
                </tr>
              </table>
            </form>
            <table width="220" height="32" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="50%" valign="bottom"><font color="#FFCC66"><strong>用户注册</strong></font></td>
                <td width="50%" align="right" valign="bottom"><font color="#FFCC33"><strong>忘记密码</strong></font></td>
              </tr>
              <tr> 
                <td height="21" colspan="2"><font color="#FFCC33">为了您注册信息的安全,请注意</font><font color="#FF6633"><strong>修改密码</strong></font></td>
              </tr>
            </table>
            </td>
        </tr>
      </table></td>
  </tr>
</table>
<br>
<br>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -