My client does not implement the HttpServlet interface. It connects to an HttpServlet running remotely
url = new URL("http://tomcat-location:8180/myContext");
This is what it uses to send messages to the servlet. But how can it get back responses? When I try to read from this location, I am reading the content of the specified page. Maybe my whole approach is wrong and this is not how the client and the servlet should talk to each other? How can I make them talk in a simple way? It seems that using the URL, they are communicating by posting and reading on that page. Is there any other way they can talk without writing on the page?
Thanks
Try this:
If you need to work with a proxy you will need to do some more work, since you will need to authenticate. Here you can read something about it: How do I make HttpURLConnection use a proxy?
If you want a client that works like a browser, you can try the HttpClient from Apache HttpComponentes
Now, if you need a behavior where the server notifies the client, so you will need to use another approaches, like creating your own server and working with sockets. If you work with a regular browser you can use websockets, but it seems that is not your case.