Which port did a request come in on?
I have a servlet that can possibly open a few ports to provide service on. When a request comes in, it is important to know which port the request came in on.
To do this, I'm using HttpServletRequest::getServerPort() which has been working beautifully. Up until now, at least.
My problem is this isn't working if the servlet sits behind a firewall, and non-standard port forwarding is taking place. For instance, if port 8888 on the firewall is forwarded to port 80 on my servlet machine, then to interact with the servlet, users will type:
http://www.somedomain.com:8888
getServerPort() seems to just parse this and says that the servlet sits on port 8888. But this isn't true, it is really listening on port 80, which is what I want to know. The servlet has no way to know or control if port forwarding is taking place, so is there a better way to determine the REAL port a HttpServletRequest came in on?
Sander Smith
[960 byte] By [
smithsaa] at [2007-10-2 5:28:01]

> Why would you need to know the port number?
Without going into too much detail, the application opens several ports to service and listens to all of them. Depending on which port a request comes in on, the application knows something about the requestor. Think of it as a cheap and easy way to demultiplex a request. I'm aware that there are alternative ways to do this, but they're not available to me because of the type of application I've got. All I want to know is what is the real port that something came in on - shouldn't be rocket science.
Sander
i am not sure i can help some what .i think Oracle appserver is running under port 8888 by default.but u didn't mention on which server you servelt's are running.but if the server is other than oracle app server ,port 8888 doesn't recognise http requests so it goes directly go to default port -80 for http requests.
i am thinking in this way for ur reply .can anybody justify this .
cheers,
babu.