getRemoteport() and getLocalPort() are new mehtods of javax.servlet.ServletRequest interface in Servlet 2.4:
getServerName and getServerPort methods returned values that getLocalName and getLocalPort now do. In version 2.4, getServerName and getServerPort have been redefined. Check the API documentation for more information.
Hello When type a url in the browser's address bar, for example http://www.YourServletIsMyServlet.com:8082 The browser opens a socket connection to the server at port 8082, (The port on which the server is listening.Then the browser redirects you to another port because that port is especially for listening to requests and then making redirection
getServerPort returns the port on which the web server is listening getRemotePort returns the port at which the client is connection with you getLocalPort returns the the port after redirection.