On 7 May 2001, Nick Holloway wrote:
> [EMAIL PROTECTED] (Craig R. McClanahan) writes:
> > On Mon, 7 May 2001, Marc Saegesser wrote:
> > > According to the JavaDoc for ServletRequest.getRemoteHost()
> > >
> > > Returns the fully qualified name of the client that sent the request, or the
> > > IP address of the client if the name cannot be determined. For HTTP
> > > servlets, same as the value of the CGI variable REMOTE_HOST.
> > >
> > > Based on that I would say that both implementations are wrong, you should
> > > never get an empty or a null value back.
> >
> > Agreed. You should get either a host name or an IP address (in string
> > form).
>
> Disagree.
>
> The CGI specification (1.1) has the following to say:
>
> * REMOTE_HOST
> The hostname making the request. If the server does not have this
> information, it should set REMOTE_ADDR and leave this unset.
>
> I would say the equivalent of not setting the REMOTE_HOST CGI variable
> is to have request.getRemoteHost() return null.
>
"Equivalent" doesn't matter any more, because the semantics for this and
several other calls are no longer identical to CGI semantics. (I've been
lobbying to get rid of all the "same as CGI variable FOO" comments in the
JavaDocs, but that is a different story ...).
Interestingly, this issue is being discussed by the JSR-053 expert group
as we speak, so a refinement in the semantics might show up in 2.3
final. In the mean time, we need to obey what the Javadocs say:
"Returns the fully qualified name of the client that
sent the request, or the IP address of the client if
the name cannot be determined."
> --
> `O O' | [EMAIL PROTECTED]
> // ^ \\ | http://www.pyrites.org.uk/
>
Craig McClanahan