Getting the Client's Address in a Servlet


public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    // Get client's IP address
    String addr = req.getRemoteAddr(); // 110.103.113.113

    // Get client's hostname
    String host = req.getRemoteHost(); //java.com
}