?? em.java
字號(hào):
package com.login;
import java.io.IOException;
import java.io.PrintWriter;
import oa.sys.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Em extends HttpServlet {
private HttpSession session=null;
private int id=0;
private String password,sqls;
private Statement stmt=null;
private ResultSet rs=null;
private RequestDispatcher dispatcher;
public Em() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb2312");
response.setContentType("text/html; charset=gb2312");
PrintWriter out = response.getWriter();
session=request.getSession();
// 獲取數(shù)據(jù)
id=Integer.parseInt((String)request.getParameter("id"));
password=request.getParameter("password");
sqls="SELECT * FROM password WHERE employeeid="+id+" AND password='"+password+"'";
Db db=new Db();
// 驗(yàn)證
try{
stmt=db.getStmtread();
rs=stmt.executeQuery(sqls);
if(rs.next()){
db.close();
session.setAttribute("id",id);
out.print("<script>parent.location.href='emlogin_ok.htm';</script>");
}
else{
//驗(yàn)證失敗
session.setAttribute("error","您輸入的用戶名或密碼錯(cuò)誤 ");
dispatcher=request.getRequestDispatcher("/error/errorpage.jsp");
dispatcher.forward(request,response);
}
}catch(Exception e){
e.printStackTrace();
}finally{
db.close();
}
}
public void init() throws ServletException {
// Put your code here
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -