My android app sends data to a servlet every 10 seconds. the servlet receives the very first request and responds back. but the servlet doesn't receive the second set of data that the client sends after the next 10 seconds. could some one please tel me how do i go about doing this. is it something related to session?
your servlet is probably finishing execution after it sent the first response.
Http is not a persistent connection protocol. You should consider issuing one http request for each set of data you need to send.
If a persistent connection is mandatory (but I don't really see what would force you to do that), you have to work with the TCP protocol... and you won't be able to use a servlet on the server-side but a specific application listening to a specific TCP port.
This sounds very much like as if you're reusing an existing URLConnection
instead of creating a new one for each request and that you're suppressing the exceptions by empty catch blocks and/or ignoring the stderr.
For each independent request, you have to create a new URLConnection
.
URL url = new URL("http://example.com");
// First request.
URLConnection connection1 = url.openConnection();
// Process it...
// Second request.
URLConnection connection2 = url.openConnection();
// Process it...
// Etc...
The session management only comes into picture when the servlet is storing something in the HttpSession
which you would like to re-access in the subsequent requests. This doesn't seem to be the case here.