Search in sources :

Example 6 with RelaDao

use of com.zyf.dao.RelaDao in project HeartWatchdogJsp by Viczyf.

the class RelaServlet method relaDelete.

private void relaDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String messages = "";
    String forward = "";
    String href = "";
    RelaDao reladao = new RelaDao();
    HttpSession session = request.getSession();
    User user = (User) session.getAttribute("user");
    int uid = user.getUid();
    int id = MyTools.strToint(request.getParameter("id"));
    boolean rs = reladao.relaDelete(id, uid);
    if (rs) {
        messages = "您已成功删除该好友";
        forward = "tishi.jsp";
        href = "RelaServlet?action=RelaList";
    } else {
        // messages = "删除好友失败,请稍后重试或检查该用户是否已经删除";
        messages = "删除失败,请返回检查";
        forward = "tishi.jsp";
        href = "RelaServlet?action=RelaList";
    }
    request.setAttribute("message", messages);
    request.setAttribute("href", href);
    RequestDispatcher requestDispatcher1 = request.getRequestDispatcher(forward);
    requestDispatcher1.forward(request, response);
}
Also used : User(com.zyf.bean.User) HttpSession(javax.servlet.http.HttpSession) RelaDao(com.zyf.dao.RelaDao) RequestDispatcher(javax.servlet.RequestDispatcher)

Aggregations

User (com.zyf.bean.User)6 RelaDao (com.zyf.dao.RelaDao)6 HttpSession (javax.servlet.http.HttpSession)6 RequestDispatcher (javax.servlet.RequestDispatcher)5 UserDao (com.zyf.dao.UserDao)1 PrintWriter (java.io.PrintWriter)1 List (java.util.List)1