Added an exception for security related exceptions
Added a try-catch block to prevent exception stack traces to be displayed
Added a check if the host name is valid (see http://shiflett.org/blog/2006/mar/server-name-versus-http-host)