| Author |
Validation of server host string
|
Jo�o Batista
Ranch Hand
Joined: May 25, 2008
Posts: 40
|
|
I was reviewing my code and noticed that I didn't include much validation on the server host string in my configuration dialog. I decided the user was free to use anything (to allow host name instead of using IP). But even if I just allow IP address, any valid IP is considered, thus when I attempt to connect to www.google.com, for instance, the application hangs in my lookup call. How can I get around this? Thanks in advance.
|
 |
k kris
Greenhorn
Joined: Nov 09, 2006
Posts: 6
|
|
Hi Batista - Are you using sockets or rmi? On RMI I can comment: The application doesn't hang. You get a . But it takes some time (around 1 min maybe which is adjustable.) Usually you do something like this to get the remote object: But when you try with google: it appears to be hanged... but you get a after a while.
Even with proper RMI Server there maybe a time lag if it's a remote machine and network traffic is high. So I think you should change the mouse cursor to Hour-Glass informing the user that we are waiting for the server to respond and change it back when we get a response or exception.
|
 |
k kris
Greenhorn
Joined: Nov 09, 2006
Posts: 6
|
|
Oops. Sorry there. I thought [CODE] works like <code> in HTML I didn't know it was <p><hr><code>...</hr></code></p>
|
 |
Soroj Margun
Ranch Hand
Joined: Jun 15, 2008
Posts: 44
|
|
Hi all, For server host, I suggest you should validate it by using java.net.InetAddress class. This class can check both IP address and host name. Hope this help.
|
SCJP 1.2; SCWCD 1.2,1.4; SCBCD 1.3; SCJD 5.0
|
 |
Jo�o Batista
Ranch Hand
Joined: May 25, 2008
Posts: 40
|
|
Many thanks for the replies! This forum rocks!
|
 |
 |
|
|
subject: Validation of server host string
|
|
|