There is no problem to obtain the host and port # while in the doPost()
or doGet() method - I just use request.getServerName() and
Request.getServerPort().
My problem is that I need these infos while in the init() method, before
any doGet() or doPost() is called.
Any idea of how to have the host name and port # while still in the
init() method??
ZartC++
> ZartC
>
> Bear in mind that "the init() method is called only once after a
> servlet is loaded, and it is guaranteed to finish before any requests
> are made to the servlet".
>
> This is quoted from the new Karl Moss Java Servlets book. You can
> certainly get the info you want in the doPost() method, which, in the
> flow of a servlet, immediately follows the init() invocation.
>
> You may already be familiar with this, but just in case - in the
> doPost() method (HttpServletRequest req)), req.getRemoteHost() should
> get you the host name. I don't know about the port number, but maybe
> req.getRequestURI() will show the port # in the contents returned...
>
> Hope this helps, Mike Drummond
>
>
>
> ----------
> From: ZartC
> To: SERVLET-INTEREST
> Subject: How to get Host name and port number
> Date: Friday, June 11, 1999 6:57AM
>
> My problem is to get the host name and the port number at init() time - i.e.
> we don't have a ServletRequest yet !
>
> ZartC++
___________________________________________________________________________
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