aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes New methods in ServletRequest 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 "New methods in ServletRequest" Watch "New methods in ServletRequest" New topic
Author

New methods in ServletRequest

Durgaprasad Guduguntla
Ranch Hand

Joined: Oct 20, 2003
Posts: 99
Hi,

Can someone explain the usage of following new methods included in ServletRequest interface and ServletRequestWrapper class in Servlet 2.4 Spec with examples:

getRemotePort()
getLocalName()
getLocalAddr()
getLocalPort()

Thanks,

Durga


Thanks,<br />Durgaprasad<br />SCJP1.4, SCWCD1.4, SCBCD1.3,<br />SCEA
alzamabar
Ranch Hand

Joined: Jul 24, 2002
Posts: 379
Originally posted by Durgaprasad Guduguntla:
Hi,

Can someone explain the usage of following new methods included in ServletRequest interface and ServletRequestWrapper class in Servlet 2.4 Spec with examples:

getRemotePort()

It gives you the port on which the client performed the request (usually 80)

getLocalName()

It gives you the name of the local machine name (usually localhost)

getLocalAddr()

It gives you the address of the local machine (usually 127.0.0.1)

getLocalPort()

It gives you the port where finally the request ended. This is a bit tricky, but try to think at the path that a request for a web application running in a servlet container follows:

1) The client performs a request for a certain url (that usually happens on port 80, which is the default for web applications) (remote port)

2) If you have set up your web container/server for listening on port 80 or, better, set the Apache server to forward any request for servlets to
your web container, the request will be forwarded from port 80 to whatever port your web container is listening on

3) Here, depending on the container, the request can be served on any internal free port on your machine (local port), and from now one it will be the container that will take care of it, until the moment when the response will be server back to the web server (if you have got one) or on your web-servlet-container-web-server


Hope this helps,

Marco

Thanks,

Durga


Marco Tedone<br />SCJP1.4,SCJP5,SCBCD,SCWCD
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
The getRemotePort() is executed on the server, and "remote" here means client port from which the request originated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New methods in ServletRequest