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

📄 login.jsp

📁 面向对象软件工程案例
💻 JSP
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--   ***********************************************************
       **项目名称:网上书店               ************************
       **内容:管理端登录界面             ************************
       **此页作者:luic                   ************************
       **完成日期:2004/4/16              ************************
       **修改: 4/20 使用JSP实现登        ************************
       **                录验证功能       ************************
       ***********************************************************
-->
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html; charset=GBK" %>
<script language="JavaScript"><!--

	if (self!=top)	top.location="login.jsp";

//--></SCRIPT>
<HTML><HEAD><TITLE>网上书店管理员登录</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
<%
	String url = "main.jsp";
	String name=new String();
	String password=new String();
	String flag = request.getParameter("flag");
   	if( flag != null && flag.equals("1"))
    {
   	name = request.getParameter("name");
   	password = request.getParameter("password");
%>
<SCRIPT>
	document.login.name.focus();

	function Login_Validator(theForm)
	{
  		if (theForm.name.value == "")
  		{
    			alert("请输入管理员账号!");
    			theForm.name.focus();
    			return (false);
  		}
  		if (theForm.password.value == "")
  		{
    			alert("请输入密码!");
    			theForm.password.focus();
    			return (false);
  		}

		return (true);
	}
</SCRIPT>
<%
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		Connection con=DriverManager.getConnection("jdbc:odbc:bookStore");
		Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
 		String SQL=new String();
		SQL = "select * from Admin  where name='" +name + "' and password='" + password + "'";
        ResultSet rs = stmt.executeQuery(SQL);
   		if(rs.next()){
   		      session.setAttribute("name",name);
        	  response.sendRedirect(url);
	        }
	        else{
%>	
<SCRIPT>
  			this.alert("登录失败!");
</SCRIPT>
<%	
                   
		}
		rs.close();
		stmt.close();
		con.close();
	}

%>
<BODY bgColor=#94d77d leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD height=78></TD></TR></TBODY></TABLE>
<TABLE height=26 cellSpacing=0 cellPadding=0 width="100%" 
background=images/home_3.gif border=0>
  <TBODY>
  <TR>
    <TD width=494><IMG height=26 src="images/home_1.gif" width=494></TD>
    <TD><IMG height=10 src="images/space.gif" 
width=1></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" 
background=images/home_6.gif border=0>
  <TBODY>
  <TR>
    <TD width=332><IMG height=165 src="images/home_4.gif" width=332></TD>
    <TD align=right width=440 background=images/home_5.gif>
      <DIV align=center>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD><IMG height=14 src="images/space.gif" 
        width=10></TD></TR></TBODY></TABLE>
      <TABLE height=42 cellSpacing=0 cellPadding=0 width=412 align=right 
      background=images/bg4.gif border=0>
        <TBODY>
        <TR>
          <FORM action="login.jsp" method=post onsubmit="return Login_Validator(this)" name="login">
          <input type="hidden" name="flag" value="1">
          <TD class=hh width=305>
            <DIV align=center><IMG height=14 src="images/space.gif" 
            width=8>用户名: <INPUT size=10 name=name> 密&nbsp;码: 
				<INPUT 
            type=password size=10 name=password> <FONT 
            color=#000000><INPUT type=hidden value=1 name=if> </FONT></DIV></TD>
          <TD align=middle width=101 height=42>
            <TABLE height=25 cellSpacing=0 cellPadding=0 width="100%" 
              border=0><TBODY>
              <TR>
                <TD height=3><IMG height=3 src="images/space.gif" 
                  width=10></TD></TR>
              <TR align=middle>
                <TD><INPUT type=image height=20 width=72 
                  src="images/gldl.gif" border=0 name=imageField2> 
              </TD></TR></TBODY></TABLE></TD></FORM></TR></TBODY></TABLE></DIV></TD>
    <TD><IMG height=10 src="images/space.gif" 
width=1></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" 
background=images/home_9.gif border=0>
  <TBODY>
  <TR>
    <TD width=304><IMG height=41 src="images/home_7.gif" width=304></TD>
    <TD colSpan=2>
      <DIV align=right><IMG height=10 src="images/space.gif" 
  width=1></DIV></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" 
background=images/home_12.gif border=0>
  <TBODY>
  <TR>
    <TD width=304><IMG height=50 src="images/home_10.gif" width=304></TD>
    <TD vAlign=top width=463 background=images/home_11.gif> </TD>
    <TD vAlign=top><IMG height=10 src="images/space.gif" 
  width=1></TD></TR></TBODY></TABLE></BODY></HTML>

⌨️ 快捷键说明

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