Knowledgebase: Java/JSP Hosting Plans
Getting the Client's Address in a Servlet
Posted by Customer Service on 25 May 2005 12:50 AM
// 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(); // 123.123.123.123
   
        // Get client's hostname
        String host = req.getRemoteHost(); // hostname.com
    }
(561 vote(s))
Helpful
Not helpful

Comments (0)