> -----Original Message----- > From: randie ursal [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 05, 2002 6:18 AM > To: [EMAIL PROTECTED] > Subject: Re: about getRemoteHost > > > i want the clients hostname...not server hostname. > > but getRemoteHost returns IP address of client not its dns hostname. > > why is this?
You can convert IP to host name yourself. Here's the relevant section of the code: String ipAddress = "123.456.789.123"; InetAddress ia = InetAddress.getByName(ipAddress); String hostname = ia.getHostName(); As you will by experimenting, the above has the desirable property of working whether ipAddress is nnn.nnn.nnn.nnn or the host name. So you can pass whatever you get from getRemoteHost() through this. The assumption you mention (the fully qualified name is available to the Solaris the server is running on) is important. The above will throw an UnkownHostException if the assumption is broken. > > Emmanuel Eze wrote: > > >use getServerName() if u want the server's ip address > > > >-----Original Message----- > >From: randie ursal [mailto:[EMAIL PROTECTED]] > >Sent: Thursday, September 05, 2002 2:54 PM > >To: [EMAIL PROTECTED] > >Subject: about getRemoteHost > > > > > >hi, > > > > sorry for this newbie question... > > > > why is getRemoteHost() of HttpServletRequest return the > > IP address of the client accessing my servlet and not the machine > > assign dns hostname? > > > >thanks > > randie > > > >_____________________________________________________________ > ______________ > >To unsubscribe, send email to [EMAIL PROTECTED] and > include in the body > >of the message "signoff SERVLET-INTEREST". > > > >Archives: http://archives.java.sun.com/archives/servlet-interest.html > >Resources: > http://java.sun.com/products/servlet/external-resources.html > >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > > > > > > > > ______________________________________________________________ > _____________ > To unsubscribe, send email to [EMAIL PROTECTED] and > include in the body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: > http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
