The case is that I whould not like to do somithing like
 this:

if( "http://machineName1:8080".equals(
 request.getRequestURL() )||
 "http://www.my_system_url:8080".equals(
 request.getRequestURL() ) ||
 "http://200.2001.148.10:8080".equals(
 request.getRequestURL() ) )
showContent1();
else if( "http://machineName2:8080".equals(
 request.getRequestURL() )||
 "http://www.my_system_url_2:8080".equals(
 request.getRequestURL() ) ||
 "http://200.2001.148.11:8080".equals(
 request.getRequestURL() ) )
showContent2();
...and so on...

I whould like to do some like this:

if( "200.2001.148.10".equals(
 request.getRequestURL().toIPAddress() )
 showContent1();
else if( "200.2001.148.11".equals(
 request.getRequestURL()toIPAddress() )
 showContent2();
...and so on...

PS:toIPAddress() is what I am looking for !
Note that in the first case the user can access the system
 in tree different forms.

but forget about it, it is just a whim...

best regards,
Junior





On Fri, 9 Aug 2002 15:21:52 -0400 
"Turner, John" <[EMAIL PROTECTED]> wrote:
>
>Well, so far you've asked two different questions, yet
> they are supposed to
>be the same.
>
>Your first post wanted an IP address from a name,
> getByName() will do that
>for you, assuming by "name" you mean fully-qualified
> internet domain name.  
>
>Now you are saying that the IP address will actually be in
> the URL, in which
>case you don't need to look it up, so it's not clear what
> you are trying to
>do.
>
>If you need to differentiate content based on whether
> someone accesses a
>resource by IP address or name, and there are many
> possible IP addresses,
>then all you have to do is test if the value returned from
> getRequestURI()
>has an IP address in it.  So rather than look for a
> specific IP address, all
>you have to do is look for ANY IP address.  That will tell
> you if someone
>entered the machine name or not.  
>
>If you need something to translate a Microsoft WINS name
> (server name) to an
>IP address, you'll need some sort of Java WINS
> library...check google...my
>guess is the SAMBA group has written one
> (http://www.samba.org) but it may
>not be generally available.
>
>John Turner
>[EMAIL PROTECTED]
>
>-----Original Message-----
>From: Jose Francisco Junior [mailto:[EMAIL PROTECTED]]
>Sent: Friday, August 09, 2002 2:55 PM
>To: Tomcat Users List
>Subject: Converting HOST to IP an IP to HOST
>
>
>All right, but it does not solve my problem. I did a local
> web system that can be accessed both by IP or HOST.
> Depending on the way the user accessed( by HOST or IP )
> the application I must display different contents. 
>
>I could do this:
>
>if(
>
 request.getRequestURL().toString().equals("192.168.20.10")
> ) 
> out.print("show IP content"); 
>else 
> ou.print("show HOST content");
>
>But the web server has many network devices and the user
> can accesss the system from many other IP and HOSTs.
>
>The InetAddress.getByName() does not work with the machine
> network name only with inet hosts.
>
>Does anybody has any idea ???
>
>
>Thanks in advice,
>Junior
>
>
>
>On Fri, 9 Aug 2002 13:50:59 -0400 
>"Turner, John" <[EMAIL PROTECTED]> wrote:
>>
>>Come on...RTFM:
>>
>>java.net.InetAddress.getByName();
>>
>>Sheesh.
>>
>>John Turner
>>[EMAIL PROTECTED]
>>
>>
>>-----Original Message-----
>>From: Jose Francisco Junior [mailto:[EMAIL PROTECTED]]
>>Sent: Friday, August 09, 2002 1:44 PM
>>To: Tomcat Users List
>>Subject: Re: Configuration for High TPS
>>
>>
>>Please,
>>
>>I know it is a bit off-topic but I am trying to get a IP
>> address from an URL like this:
>>new URL("http://java.sun.com";); //this is the URL
>>
>>How can I get the IP address from this URL? Any idea ??
>>
>>
>>Thanks in advance,
>>Junior 
>>________________________________________________
>>Don't E-Mail, ZipMail! http://www.zipmail.com/
>>
>>--
>>To unsubscribe, e-mail:
>><mailto:[EMAIL PROTECTED]>
>>For additional commands, e-mail:
>><mailto:[EMAIL PROTECTED]>
>>
>>--
>>To unsubscribe, e-mail:
>>   <mailto:[EMAIL PROTECTED]>
>>For additional commands, e-mail:
>> <mailto:[EMAIL PROTECTED]>
>>
>
>-----------------------------------------
>Prefiro as l�grimas da derrota
>do que a vergonha de n�o ter lutado... 
>
>Willan Brook
>-----------------------------------------
>________________________________________________
>Don't E-Mail, ZipMail! http://www.zipmail.com/
>
>--
>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>
>--
>To unsubscribe, e-mail:
>   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>

-----------------------------------------
Prefiro as l�grimas da derrota
do que a vergonha de n�o ter lutado... 

Willan Brook
-----------------------------------------
________________________________________________
Don't E-Mail, ZipMail! http://www.zipmail.com/

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to