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

confusion about request's API...

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some methods of ServletRequest:

1] getRemotePort()
2] getServerPort()
3] getLocalPort()

First one gives the port number of client, server can call this on request object.

Second and third gives port numbers of server (getServerPort() returns port number where server listen request and getLocalPort() returns port number where server transfer that request for complition (so it can handle another request on previous one).

But my doubt is infomation about server should come from response because this is the thing which client gets from server...

Before that, what is the need of getting these information about server. Who can use it and how?

Please clear my doubts...

Thanks a lot.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The local port serving the request is not necessarily the same port the request was made on by the client. Depending on what you are trying to do you may need either port. eg forwarding from apache to tomcat, the client requests data on port 80 from apache, apache requests data from tomcat on another port (8008? I forget)
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
The local port serving the request is not necessarily the same port the request was made on by the client. Depending on what you are trying to do you may need either port. eg forwarding from apache to tomcat, the client requests data on port 80 from apache, apache requests data from tomcat on another port (8008? I forget)


I agree, but my doubt is different... please read my post, what I meant..


 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rathi ji:
But my doubt is infomation about server should come from response because this is the thing which client gets from server...


You're thinking 'client-centric', ie from the point of view of the client. In a servlet you should think in term of the server. The request comes in on port XXXX therefor we use this when parsing the request and deciding how to respond to the client.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:


You're thinking 'client-centric', ie from the point of view of the client. In a servlet you should think in term of the server. The request comes in on port XXXX therefor we use this when parsing the request and deciding how to respond to the client.


Okay, does it mean that if server forwards request to another port then it add these port numbers (server port and local port) to request.

Is this right?
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic