日期:2014-05-17 浏览次数:20930 次
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.Statement"%> <%@page import="java.sql.ResultSet"%> <%@page import="java.text.SimpleDateFormat"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'login2.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <jsp:useBean id="db" scope="page" class="com.cn.db.OpenDb"></jsp:useBean> <body> <% String uid = request.getParameter("uid"); String pwd = request.getParameter("pwd"); String sql = "select * from userinfo where uid = '" + uid + "'" + " and pwd = '" + pwd +"'" ; Connection conn = db.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); if(rs.next()){ rs.close(); String lastTime = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm").format(new Date()); sql = "update userinfo set loginTimes = loginTimes + 1 , lastTime = '" + lastTime +"' where uid = '"+ uid +"'"; stmt.execute(sql); stmt.close(); conn.close(); session.putValue("uid",uid); %> <script type="text/javascript"> self.location="all.jsp"; </script> <% }else{ rs.close(); stmt.close(); conn.close(); } %> <script type="text/javascript"> alert("对不起,您输入有错误,请重新输入"); history.back(); </script> </body> </html>