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

New methods in ServletRequest

 
Durgaprasad Guduguntla
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nitish Bahadur
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getRemotePort() is executed on the server, and "remote" here means client port from which the request originated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic