In many Java web applications, there is a need to extract the host name and port from an incoming HTTP…