Ai giúp sửa sửa lỗi này với ạ (Cannot forward after response has been committed) trong servlet ạ

e muốn khi có action “add” sau khi thêm dữ liệu xong thì nó sẽ chuyển sang trang /admin/insert_product.jsp nhưng nó không dc và hiện lỗi kia ạ

 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Date;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import model.Category;
import model.CategoryDAO;
import model.Product;
import model.ProductDAO;

/**
 *
 * @author 8470p
 */
@MultipartConfig(fileSizeThreshold = 1024 * 1024 * 2, // 2MB
        maxFileSize = 1024 * 1024 * 10, // 10MB
        maxRequestSize = 1024 * 1024 * 50)
public class ManagerProductServlet extends HttpServlet {

    DecimalFormat formatter = new DecimalFormat("###,###,###");
    SimpleDateFormat simpledate = new SimpleDateFormat("yyyy-MM-dd");
    ProductDAO spDao = new ProductDAO();

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        request.setCharacterEncoding("UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            String id = request.getParameter("id");
            String name = request.getParameter("name");
            String quantity = request.getParameter("quantity");
            String price = request.getParameter("price");
            // String publishday = request.getParameter("publishday");
            String idDanhMuc = request.getParameter("idDanhMuc");
            String action = request.getParameter("action");
            // System.out.println(request.getParameter("anh"));
            switch (action) {

                case "delete":

                    if (spDao.deleteProduct(id) == 1) {
                        request.getRequestDispatcher("/admin/manager_product.jsp").forward(request, response);
                        return;
                    }
                    break;
                case "edit":

                    request.setAttribute("PRODUCT", ProductDAO.gettProductbyID(id));
                    request.setAttribute("CATEGORY_ID", ProductDAO.gettProductbyID(id).getIdDanhMuc());
                    //  out.print("haha");
                    request.getRequestDispatcher("/admin/update_product.jsp").forward(request, response);
                    return;
                case "update":
                    Product pr = new Product(Integer.parseInt(id), name, Integer.parseInt(quantity),
                            Double.parseDouble(price), new Category(idDanhMuc, ""), "");
                    if (spDao.updateSanPham(pr) == 1) {
                        request.setAttribute("thongbao3", true);
                        request.setAttribute("LIST_SANPHAM", spDao.getAllSanPham());
                        System.out.println("LIST_SANPHAM:" + spDao.getAllSanPham().size());
                        request.getRequestDispatcher("/admin/manager_product.jsp").forward(request, response);
                        return;
                    } else {
                        request.setAttribute("thongbao3", false);
                        request.getRequestDispatcher("/admin/update_product.jsp").forward(request, response);
                        return;

                    }

                case "showproduct":

                    request.setAttribute("PRODU_DETAIL", ProductDAO.gettProductbyID(id));
                    request.setAttribute("PRODU_DETAIL_price", formatter.format(ProductDAO.gettProductbyID(id).getPrice()));
                    request.getRequestDispatcher("productdetail.jsp").forward(request, response);
                    // return;
                    break;

            }

        } catch (SQLException ex) {

        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        processRequest(request, response);
        doPost(request, response);

    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
        String id = request.getParameter("id");
        String name = request.getParameter("name");
        String quantity = request.getParameter("quantity");
        String price = request.getParameter("price");
        // String publishday = request.getParameter("publishday");
        String idDanhMuc = request.getParameter("idDanhMuc");
        String action = request.getParameter("action");
        Part part = request.getPart("file");
        String fileName = extractFileName(part);
        String savePath = "C:\\Users\\8470p\\Downloads\\tSHOP\\tuyentqpd02042_gd1\\Shop1\\web\\images\\" + File.separator + fileName;
        File fileSaveDir = new File(savePath);
        /*if you may have more than one files with same name then you can calculate some random characters
            and append that characters in fileName so that it will  make your each image name identical.*/

        part.write(savePath + File.separator);
        switch (action) {
            case "add":
                //out.print(request.getContextPath()+"/"+request.getParameter("anh"));
                Product sp = new Product(Integer.parseInt(id), name, Integer.parseInt(quantity),
                        Double.parseDouble(price), new Category(idDanhMuc, ""), fileName);

                RequestDispatcher vew = request.getRequestDispatcher("/admin/insert_product.jsp");
                try {
                    if (spDao.addSanPham(sp) == 1) {
                        //  part.write(savePath + File.separator);

                        request.setAttribute("thongbao2", true);
                        request.setAttribute("LIST_SANPHAM", spDao.getAllSanPham());
                        System.out.println("LIST_SANPHAM:" + spDao.getAllSanPham().size());

                        vew.forward(request, response);
                        return;

                    } else {
                        request.getRequestDispatcher(request.getContextPath() + "/admin/insert_product.jsp").forward(request, response);
                        return;
                    }
                } catch (SQLException ex) {
//                        request.getRequestDispatcher(request.getContextPath() + "/admin/insert_product.jsp").forward(request, response);
                }

                break;
        }
    }
//    request.getRequestDispatcher("/admin/insert_product.jsp").forward(request, response);}

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

    private String extractFileName(Part part) {
        String contentDisp = part.getHeader("content-disposition");
        String[] items = contentDisp.split(";");
        for (String s : items) {
            if (s.trim().startsWith("filename")) {
                return s.substring(s.indexOf("=") + 2, s.length() - 1);
            }
        }
        return "";
    }

}

e muốn khi có action “add” sau khi thêm dữ liệu xong thì nó sẽ chuyển sang trang /admin/insert_product.jsp nhưng nó không dc và hiện lỗi kia ạ

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?