Question:

How do I work with the Host name cache on a client computer?

by Guest7322  |  12 years, 7 month(s) ago

0 LIKES UnLike

How do I work with the Host name cache on a client computer?

 Tags: cache, Client, computer, HOST, name

   Report

1 ANSWERS

  1. jane
    hello

    I assume you're talking HttpServletRequest here. Read your API's:
    getRemoteAddr--Returns the Internet Protocol (IP) address of the client or
    last proxy that sent the request.
    getRemoteHost--Returns the fully qualified name of the client or the last
    proxy that sent the request. If the engine cannot or chooses not to resolve
    the hostname (to improve performance), this method returns the dotted-string
    form of the IP address.
    getRemoteUser--Returns the login of the user making this request, if the
    user has been authenticated, or null if the user has not been authenticated.

    So first notice that getRemoteAddr and getRemoteHost both may not get the
    client's machine. If the request came through a proxy, it will get that.
    Second, if getRemoteHost is giving an IP, it may not be able to get a host
    name. Third, you can't get a user name if the server from which the request
    is coming does not require login. That said, if you have an IP address, you
    can attempt to get a host name like this:
    String ip = "127.0.0.1";
    String hostName = InetAddress.getByName(ip).getHostName(); // or
    ..getCanonicalHostName()

    See http://java.sun.com/j2se/1.4.1/docs/...etAddress.html for
    more info on getHostName and such.


    OR

    (1) Go to.... /conf/server.xml

    (2) Locate the following part:


    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />

    (3) Change enableLookups="true"

    (4) Now, restart tomcat and reload the jsp containing getRemoteHost() method! Hope you should see the host name now. It may not work through proxy, so you can override proxy for local addresses.


    hope it helps

Sign In or Sign Up now to answser this question!

Question Stats

Latest activity: 14 years, 7 month(s) ago.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions