Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Request server port methods  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the following methods used for: request.getServerPort(), request.getRemotePort() & request.getLocalPort()? What's the difference between these methods?
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

for more description of these methods check this..
New Features in Servlet 2.4
 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Hope that the information was useful
 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!