aspose file tools*
The moose likes Servlets and the fly likes confusion about request's API... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "confusion about request Watch "confusion about request New topic
Author

confusion about request's API...

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Oct 11, 2004
Posts: 3830
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confusion about request's API...