Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX Contractors 2.1.1: Validating Hostname Input

 
Paul Tongyoo
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all--
Is there a valid format for a server's hostname? I'm thinking about using a regular expression to validate input, but what should its restrictions be? .com at the end? Only letters, numbers, and periods allowed?
Thanks in advance,
Paul
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
I wouldn't try and validate the hostname - there is just too much work involved. There are very few systems that really validate the hostname: what most do is simply try to look up an internet address for that hostname, and if that works, then they use it (which is why so many were upset with Verisign's breaking DNS a month or so ago).
I didn't even go that far with my assignment: whatever the user gave me I used. By default I offered "localhost" as the possible location.
Regards, Andrew
 
Paul Tongyoo
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrew -- Paul
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic