• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about request.getServletPort() method

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic