@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        
        try {
            
            if ( (request.getParameter("quantity1") != null) && (request.getParameter("quantity2") != null) && (request.getParameter("quantity3") != null)) 
                    {
                            String quantity1 = request.getParameter("quantity1");
                            String quantity2 = request.getParameter("quantity2");
                            String quantity3 = request.getParameter("quantity3");
                    }

       if ((request.getParameter("quantity1")!= null) && (request.getParameter("quantity2")!= null) && (request.getParameter("quantity3")!= null))
                    {

                            String quantity1 = request.getParameter("quantity1");
                            String quantity2 = request.getParameter("quantity2");
                            String quantity3 = request.getParameter("quantity3");
   
                            if(quantity1==null ) quantity1="";
                            if(quantity2==null ) quantity2="";   
                            if(quantity3==null ) quantity3="";

                            Date nowq1 = new Date();
                            Date nowq2 = new Date();
                            Date nowq3 = new Date();
                            String timestampq1 = nowq1.toString();
                            String timestampq2 = nowq2.toString();
                            String timestampq3 = nowq3.toString();
                            Cookie cookieq1 = new Cookie ("quantity1",quantity1);
                            Cookie cookieq2 = new Cookie ("quantity2",quantity2);
                            Cookie cookieq3 = new Cookie ("quantity3",quantity3);
                            cookieq1.setMaxAge(365 * 24 * 60 * 60);
                            cookieq2.setMaxAge(365 * 24 * 60 * 60);
                            cookieq3.setMaxAge(365 * 24 * 60 * 60);
                            response.addCookie(cookieq1);
                            response.addCookie(cookieq2);
                            response.addCookie(cookieq3);
                    }    
       
                    RequestDispatcher view = request.getRequestDispatcher("index.jsp");
                    view.forward(request, response);
            }
            
         finally {            
            out.close();
        }
    }