On the client side you are looking at creating a URLConnection to the URL of a servlet, opening a stream, writing a request and reading a response stream. URLConnection is in the java.net package, part of the standard SDK library.
The alternative would be to open a socket, but URLConnection is simpler.
On the server side you are obviously talking about a class derived from HttpServlet. You can download
Tomcat and get the API docs.
Bill