<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
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></title>
<style type="text/css">
body{ font-size:13px; font-family:"宋体";}
body,form,input,p{ padding:0; margin:0; border:0;}
form{
width:300px;
height:200px;
padding-top:20px;
margin:60px auto;
background:#2aa 6ea;
border-radius:30px;
border:2px solid #4faccb;
}
p{
margin-top:20px;
text-align:center;
}
p span{
width:30px;
display:inline-block;
text-align:right;
}
.num,.pass{
width:152px;
height:18px;
border:1px solid #38a1bf;
padding:2px 2px 2px 22px;
}
.num{
background:url(images/1.jpg) no-repeat 5px center #FFF;
color:#999;
}
.pass{
background:url(images/2.jpag) no-repeat 5px center #FFF;
}
.btn01,.btn02{
width:60px;
height:25px;
border-radius:3px;
border:1px solid #6b5d50;
margin-left:30px;
}
.btn02{ background:#3aa7ea;}
</style>
</head>
<body>
<form action="dologin.jsp" method="post" autocomplete="on">
<p>
<span>账号:</span>
<input type="text" name="user" class="num" />
</p>
<p>
<span>密码:</span>
<input type="password" name="password" class="pass"/>
</p>
<p><span>验证码</span><input type="text" name="code"/>qwer</p>
<p>
<input type="submit" class="btn02" value="登录"/>
</p>
</form>
</body>
</html>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"
import=" javax.servlet.http.HttpSession"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("UTF-8");
HttpSession s = request.getSession();
String username = request.getParameter("username");
String password1 = request.getParameter("password");
Class clazz = Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/school";
String user = "root";
String password = "root";
Connection conn = DriverManager.getConnection(url, user, password);
PreparedStatement ps = conn.prepareStatement("select uname,upwd from user where uname = ? and upwd = ?");
ps.setString(1, username);
ps.setString(2, password1);
ResultSet rs = ps.executeQuery();
if(rs.next()){
session.setAttribute("username", username);
session.setAttribute("password", password1);
response.sendRedirect("/school/success.jsp");
}else{
response.sendRedirect("/school/loginyanzheng2.jsp");
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>title</title>
</head>
<body>
<%
String username = (String) request.getSession().getAttribute("username");
%>
欢迎你<%=username%>
</body>
</html>