my dog learned polymorphism
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Server Port  Vs Local Port Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Server Port  Vs Local Port" Watch "Server Port  Vs Local Port" New topic

Server Port Vs Local Port

Sarat Koduri
Ranch Hand

Joined: Jul 08, 2008
Posts: 83
some body please clarify the following .. thing..

PortA serverbox PortB

support client has sent a request to porta and finnally it is served by portb.

as per the HFSJ..
Serverport is portA
Local Port is portB

but i hv seen the servlet spect 2.4.. they say ..
Local Port is portA
and there is nothing mentioned related to server port .. so just got confused.

some body kindly tell me which is exactly the Server port and local port..
Michael Vargenstien
Ranch Hand

Joined: Jan 27, 2007
Posts: 61
Okay dude, I don't really get your question but I'll let you know the terminology.

getServetPort() basically will return the default port that the server is listening on. So for example, suppose you got Tomcat 5.x/6.x runnin. The default port (out of the box) is 8080. This is the port, teh server is actually listening on.

getLocalPort() is the actual port being used to service the request. Think about one million concurrent requests being sent at the same time. The container (tomcat/websphere/jboss) will internally use a port to actually service the request...why? To handle concurrent requests at the same time.

Remember one servlet, many threads. Ports are communication channels between the container. the app and the OS. They are reserved internally by the container to distinguish each apart. So if concurrent requests are being served, the container will internally use a specific port to service thread A and B.

Hope that helps.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks Michael Vargenstien
I agree. Here's the link:
subject: Server Port Vs Local Port
It's not a secret anymore!