• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about request.getServletPort() method

 
Sandra Sharpe
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing jsp's and servlets with an Apache/Jserv configuration. Recently, we configured our web server to listen for requests on port 4158. However, when a jsp calls the ServletRequest.getServletPort() method, the value returned is 80, not 4158 which was the port the request was received on.
Does anyone know why this is happening? Where can I find more information about this topic? Is there a different method I can use to retrieve the correct value?
Thank You,
Sandra
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am assuming you meant getServerPort. Which returns the port on which the request was received. I am not sure why it's not returning what you expected. Mine returns 80, and that's because I am runing on localHost:8080.
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!