Hi folks!
I have an Java Application that communicates with a servlet by the ObjectInput and ObjectOutput Streams.
I made it work to send and receive data.
The problem is that when I have to send an object to servlet and to receive an object from servlet, my application does two diferent requests to this servlet.
It follows the code:
{
// send data to the servlet
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject(obj);
oos.flush();
// receive data from servlet
InputStream instr = con.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
Object result = inputFromServlet.readObject();
inputFromServlet.close();
oos.close();
instr.close();
return result;
}
How can I change it to make only one request to servlet, sending and receiving an object from it.
Thanks!
Jo�o Cunha
I have an Java Application that communicates with a servlet by the ObjectInput and ObjectOutput Streams.
I made it work to send and receive data.
The problem is that when I have to send an object to servlet and to receive an object from servlet, my application does two diferent requests to this servlet.
It follows the code:
{
// send data to the servlet
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject(obj);
oos.flush();
// receive data from servlet
InputStream instr = con.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
Object result = inputFromServlet.readObject();
inputFromServlet.close();
oos.close();
instr.close();
return result;
}
How can I change it to make only one request to servlet, sending and receiving an object from it.
Thanks!
Jo�o Cunha