protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        Map<String, Object> rpta = new HashMap<String, Object>();
        String opc = request.getParameter("opc");
        HttpSession sesion = request.getSession(true);
        InterfaceContratoDAO con = new ContratoDAO();
        InterfacePlantillaContractualDAO pl = new PlantillaContractualDAO();
        try {
            /* TODO output your page here. You may use following sample code. */
            if (opc.equals("Imprimir")) {
                String[] id_con = request.getParameterValues("Imprimir");
                List<String> list = new ArrayList<String>();
                for (int i = 0; i < id_con.length; i++) {
                    list.add(id_con[i]);
                }
                sesion.setAttribute("lista", list);
                response.sendRedirect("Vista/Contrato/Formato_Plantilla/Impresion_Masiva.jsp");
                // out.print(list.get(0).toString());
            }
            if (opc.equals("Imprimir1")) {
                String[] id_con = request.getParameterValues("Imprimir");

                List<String> list = new ArrayList<String>();
                List<String> texto = new ArrayList<String>();
                for (int i = 0; i < id_con.length; i++) {
                    String[] alma;
                    String textor="";
                    String imprimir="";
                    list.add(id_con[i]);
                    alma = id_con[i].split("/");
                   // String ubicacion = "/var/lib/tomcat7/webapps/TALENTO_HUMANO/Vista/Contrato/Formato_Plantilla/Formato/";
                    //String ubicacion = getServletContext().getRealPath(".").substring(0, getServletContext().getRealPath(".").length() - 11)+"web\\Vista\\Contrato\\Formato_Plantilla\\Formato\\";
                    //String ubicacion=getServletConfig().getServletContext().getRealPath("/")+"Vista/Contrato/Formato_Plantilla/Formato/";
                    String ubicacion=FactoryConnectionDB.url+"Formato/";
                  
                    
                    String no_arhivo_or = pl.List_pl_con_x_id(alma[1]);
                    FileReader lector = new FileReader(ubicacion + no_arhivo_or.trim());
                    BufferedReader contenido = new BufferedReader(lector);
                    while ((textor = contenido.readLine()) != null) {
                        imprimir =imprimir+ textor;
                    }
                    texto.add(imprimir);
                }
                sesion.setAttribute("lista", list);
                sesion.setAttribute("texto", texto);
                response.sendRedirect("Vista/Contrato/Formato_Plantilla/Impresion_Masiva2.jsp");
                // out.print(list.get(0).toString());
            }
            if (opc.equals("Listar_contrato")) {
                String id = request.getParameter("id");
                List<Map<String, ?>> list = con.List_contra_x_idcto_json(id);
                // out.print(list.get(0).toString());
                rpta.put("rpta", "1");
                rpta.put("lista", list);
            }
        } catch (Exception e) {
            rpta.put("rpta", "-1");
            rpta.put("mensaje", e.getMessage());
        }
        Gson gson = new Gson();
        out.println(gson.toJson(rpta));
        out.flush();
        out.close();
    }