Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request server port methods

 
Vinay Joseph
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?
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
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
 
Khaled Mahmoud
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic