File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Request server port methods 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 "Request server port methods" Watch "Request server port methods" New topic
Author

Request server port methods

Vinay Joseph
Greenhorn

Joined: Jun 05, 2006
Posts: 4
What are the following methods used for: request.getServerPort(), request.getRemotePort() & request.getLocalPort()? What's the difference between these methods?
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

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


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
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


SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
 
jQuery in Action, 2nd edition
 
subject: Request server port methods
 
Similar Threads
servlet security
Lucene - get TermVector positions
Inheritance of all members
How do OBJECTS pass messages in Java?
What is the logic behind calls like JOptionPane.method()