try{ URL url2=new URL("http","localhost",8081,"/servlet/Comptage?"); URLConnection conn2 = url2.openConnection(); conn2.setDoOutput(true); conn2.setUseCaches (false); conn2.setDefaultUseCaches(false); ObjectOutputStream sortie=new ObjectOutputStream(conn2.getOutputStream()); sortie.writeObject(critselect); i=0; for(i=0;i<nbongrest-1;i++){ sortie.writeObject(tabselect[i]); } sortie.flush(); sortie.close(); phrase.setText("Objets envoyés a la servlet?"+(i+1)); }catch(IOException ioe){ System.out.println("Erreur d'entrée/sortie: " + ioe.getMessage()); }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); try{ AccesBdd count=new AccesBdd(); count.connect("comptage"); //reception par la methode post des divers tableaux ObjectInputStream e = new ObjectInputStream(request.getInputStream()); String[] critselect=(String[])e.readObject(); int nbong=critselect.length; tabcritsel=new String[nbong][]; for(int i=0;i<nbong;i++){ tabcritsel[i]=(String[])e.readObject(); //count.comptage(critselect[i],tabcritsel[i]); } e.close(); //count.deconnec(); }catch(Exception e){ System.out.println("Erreur:" + e.getMessage()); } }