protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession();
        if(session != null){
            String sleeveInput = (String) session.getAttribute("sleeveInput");
            String openedPacks = request.getParameter("openedPacks");
            if (sleeveInput == null || sleeveInput.replaceAll("[^1-5\\-]", "").length() != 38){
                writeResponse(response, "{\"error\" : \"selectSleeves\"}");
                return;
            } else {
                try {
                    api = new BoxMappingApi("GTC");
                } catch (Throwable ex) {
                    writeResponse(response, "{\"error\" : \"setIsNotRecognised\"}");
                    return;
                }
                api.setSleeves(sleeveInput);
                //api.setSleeves("123452534123-315241452315-534123241534");
            }
            
            if(openedPacks != null && !openedPacks.isEmpty()){
                String[] packs = openedPacks.split("\n");
                for (int i = 0; i < packs.length; i++) {
                    boolean hasNext = !(i == packs.length- 1);
                    String[] packInfo = packs[i].split("-");
                    if (packInfo.length != 2) {
                        System.out.println("Invalid opened pack info. Discarding " + packs[i] + ", example: L03-SoulRansom");
                    } else {
                        try{
                            api.selectCard(packInfo[0], packInfo[1], hasNext);
                        } catch (Exception e){
                            writeResponse(response, "{\"error\" : \"invalidEntryOrWrongRow\"}");
                            return;
                        }
                    }
                }
            }
            
            writeResponse(response, api.jsonShowAll());
        }
    }