private void buyCompany(int id, HttpServletResponse response, RequestContext rc) throws IOException, SQLException {
        int requesterId = rc.getId();
        int compNum = UserManager.countCompanies(requesterId);
        long reregTax = CompanyManager.companyCost(compNum + 1);
        if(reregTax != -1) {
            if(!CompanyManager.ownsCompany(id, requesterId)) {
                long curBalance = rc.getMoney();
                long sellCost = CompanyManager.getSellCost(id);
                if(curBalance >= sellCost) {
                    if(reregTax < curBalance - sellCost) {
                        try {
                            NotificationManager.generateBuy(id, requesterId);
                            CompanyManager.buyCompany(id, requesterId);
                        } catch(IllegalArgumentException e) {
                            response.sendRedirect("teams.jsp?err=permdenied");
                            return;
                        }
                        response.sendRedirect("team.jsp?id=" + id);
                    } else {
                        response.sendRedirect("teams.jsp?err=poor");
                    }
                } else {
                    response.sendRedirect("teams.jsp?err=poor");
                }
            } else {
                response.sendRedirect("teams.jsp?err=permdenied");
            }
        } else {
            response.sendRedirect("teams.jsp?err=full");
        }
    }