Package com.sugar.servlets

Source Code of com.sugar.servlets.DeleteUserServlet

package com.sugar.servlets;

import com.sugar.users.SystemUsers;
import com.sugar.users.User;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
*
* @author LordNighton
*
*/

@WebServlet(name = "DeleteUserServlet", urlPatterns = {"/DeleteUserServlet"})
public class DeleteUserServlet extends HttpServlet {

    protected void processRequest (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType ("text/html;charset=UTF-8");
       
        String userToDeleteLogin = (String) request.getParameter ("delete");
       
        SystemUsers sysUsers = (SystemUsers) request.getServletContext().getAttribute ("sysUsers");
        List <User> usersList = sysUsers.getUsers();
       
        usersList.remove (sysUsers.getUserByLogin (userToDeleteLogin));
       
        response.sendRedirect ("protected/adminPanel.jsp");
    }
   
    @Override
    protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        processRequest (request, response);
    }

    @Override
    public String getServletInfo() {
        return "Delete user servlet";
    }
   
}
TOP

Related Classes of com.sugar.servlets.DeleteUserServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.