protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date d = new Date();
        String date = dateFormat.format(d);

        try {

            String message, url = "/index.jsp";
            String dbURL = "jdbc:mysql://localhost:3306/itrs";
            String username = "root";
            String dbpassword = "sesame";
            try
            {
                Class.forName("com.mysql.jdbc.Driver");

            }
            catch (ClassNotFoundException e)
            {}


            String type = request.getParameter("type");
            PaidRequest paid = new PaidRequest();
            CompRequest comp = new CompRequest();

            if (type.equalsIgnoreCase("comp"))
            {
                url = "/RequestConfirmation.jsp";
                comp = (CompRequest) request.getSession().getAttribute("newComp");
                out.println(comp);
                try
                {
                    Connection conn = DriverManager.getConnection(dbURL, username, dbpassword);
                    
                    
                    String command = "INSERT INTO comprequest VALUE(NULL," + comp.getAcctNum() + "," +
                            comp.getDepNum() + "," + comp.getGameNum() + "," + comp.getSecNum() + "," +
                            comp.getReqSeats() + ",?,?," +
                            "null," + comp.getLocNA() + "," + comp.getToi() + ",0,CURDATE(),null,null,null)";
                    request.getSession().setAttribute("comm", command);
                    PreparedStatement s = conn.prepareStatement(command);
                    s.setString(1, comp.getRecipient());
                    s.setString(2, comp.getPurpose());

                    s.executeUpdate();
                    
                   
                    
                    request.getSession().setAttribute("warning", s.getWarnings());
                    ResultSet r = s.executeQuery("SELECT LAST_INSERT_ID()");
                    int reqNumber = -1;
                    if(r.next())
                    {
                        reqNumber = r.getInt(1);
                    }
                    r.close();
                    request.getSession().setAttribute("reqNumber", reqNumber);
                    request.getSession().setAttribute("request", comp);


                }
                catch (SQLException sqle)
                {

                }

            }
            if (type.equalsIgnoreCase("paid"))
            {
                url = "/RequestConfirmation.jsp";
                paid = (PaidRequest) request.getSession().getAttribute("newPaid");
                out.println(paid);
                try
                {
                    Connection conn = DriverManager.getConnection(dbURL, username, dbpassword);


                    String command = "INSERT INTO paidrequest VALUE(NULL," + paid.getAcctNum() + "," +
                            paid.getDepNum() + "," + paid.getGameNum() + "," + paid.getSecNum() + "," +
                            paid.getReqSeats() + ",null,0," + paid.getLocNA() + "," + paid.getToi() + "," +
                            "?,?,?,?,?,0,CURDATE(),null,null)";
                    request.getSession().setAttribute("comm", command);
                    PreparedStatement s = conn.prepareStatement(command);
                    s.setString(1, paid.getCardType());
                    s.setString(2, paid.getCardNum());
                    s.setString(3, paid.getCardSecNum());
                    s.setString(4, paid.getCardExpir());
                    s.setString(5, paid.getRecipient());
                   
                    s.executeUpdate();



                    request.getSession().setAttribute("warning", s.getWarnings());
                    ResultSet r = s.executeQuery("SELECT LAST_INSERT_ID()");
                    int reqNumber = -1;
                    if(r.next())
                    {
                        reqNumber = r.getInt(1);
                    }
                    r.close();
                    request.getSession().setAttribute("reqNumber", reqNumber);
                    request.getSession().setAttribute("request", paid);


                }
                catch (SQLException sqle)
                {

                }

            }
            RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
            dispatcher.forward(request, response);
           
        } 
        finally
        {
            out.close();
        }

    }