Grazie mille dell'interessamento!
Dunque..io non so di preciso quello che ho fatto:
Questo è la classe della servlet che mi serve per estrarre i dati:
codice:
public class Prova6 extends HttpServlet
{
public void service
(HttpServletRequest req,
HttpServletResponse res)
throws IOException, ServletException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
.....
Poi sempre all'interno di questa classe(nel try che tenta il collegamento al db) ho fatto anche il collegamento col server tramite socket così:
codice:
try{
s= new Socket("localhost", 11113);
ObjectInputStream is1 = new ObjectInputStream(s.getInputStream());
ObjectOutputStream os1 = new ObjectOutputStream(s.getOutputStream());
DataInputStream is3 = new DataInputStream(s.getInputStream());
DataOutputStream os2 = new DataOutputStream(s.getOutputStream());
for (int j=0; j<y; j++)
{
os1.writeObject(ingy[j]); //array ingr ricetta
os2.writeFloat(qtyy[j]); //qtà ricetta
}
n = (int)is3.read();
ingout = new String[n];
qtyout = new float[n];
ingout = (String[]) is1.readObject(); //array di output(dal server) di ingr da comprare e qtà
qtyout = (float[]) is1.readObject();
out.println("<center>");
out.println("<font face=cursive size=6>Lista della spesa: </font>");
for (int j=0; j<ingout.length; j++){ out.println("<fontface=cursive><h3>"+ingout[j]+":"+qtyout[j]+"</h3></font></br>");
}
os1.close();
os2.close();
is1.close();
is3.close();
}
catch(UnknownHostException e){
out.println("Host Unknown");
}
catch(Exception e){
out.println(e);
}
out.println("<center>");
out.println("</body>");
out.println("</html>");
r1.close();
s1.close();
c1.close();
}
Poi ho fatto il server che riprende quei dati e li confronta coi suoi.
Lancio tomcat ma il tutto non funziona.
Per ora il problema non è il server(credo) perchè l'errore che mi da è dato dal fallimento della connessione col server..
Quindi non va sicuramente bene come ho fatto il client!
C'è qualcuno che sa darmi una dritta su come devo fare?
Grazie!!!