Extract common code into a new method to reduce duplication identified by Simian.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1623456 13f79535-47bb-0310-9956-ffa450edef68
Pull up common code to reduce duplication identified by Simian.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1623458 13f79535-47bb-0310-9956-ffa450edef68