This Java tip illustrates a method of getting the client's address in a Servlet. In an embodiment developer may use this tip in their client server applications for knowing at the server end the address of the client which made the request.

  // This method is called by the servlet container to process a GET request.
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        // Get client's IP address
        String addr = req.getRemoteAddr(); //
        // Get client's hostname
        String host = req.getRemoteHost(); //