There are usually 2 ports involved. One is the one that the URL came in on, and is commonly port 80, with Apache listening.
The second port is the port that Apache piped the JSP request to for your JSP server to handle. For example port 8008 for the
Tomcat WarpConnector.
If the port's being extracted from the original URL, 80 would be proper. That would tell you how the request came from the Inter (or Intra ) Net.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.