日期:2014-05-18 浏览次数:20677 次
package com.fuyou.servlet; import java.io.IOException; import java.sql.ResultSet; import java.sql.SQLException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.fuyou.util.DBConnection; import com.fuyou.util.mvconnection; public class loginservlet extends HttpServlet { private DBConnection dbc = new DBConnection(); private static final long serialVersionUID = -3265621922663327137L; public loginservlet() { } public void destroy() { super.destroy(); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); String conformPswd = ""; String sql = "select * from user where username='" + username + "'"; ResultSet rs = null; mvconnection mvc = new mvconnection(); if (mvc != null) { rs = mvc.getResultSet(sql); } else { return; } if (rs != null) { try { if (rs.getString("password") != null) { conformPswd = rs.getString("PASSWORD"); } return; } catch (SQLException e) { e.printStackTrace(); } finally { this.dbc.closeResultSet(rs); } } if (password.equals(conformPswd)) { } } public void init() throws ServletException { } }