aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ServlerRequest Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ServlerRequest Methods" Watch "ServlerRequest Methods" New topic
Author

ServlerRequest Methods

Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Hi all,

I am reading API I have got the following methods and descriptions.
getServerPort : Returns the port number to which the request was sent
getServerName : Returns the host name of the server to which the request was sent.

getRemotePort : Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
getRemoteAddr :Returns the Internet Protocol (IP) address of the client or last proxy that sent the request
getRemoteHost: Returns the fully qualified name of the client or the last proxy that sent the request.

getLocalName:Returns the host name of the Internet Protocol (IP) interface on which the request was received.
getLocalPort :Returns the Internet Protocol (IP) port number of the interface on which the request was received.
getLocalAddr : Returns the Internet Protocol (IP) address of the interface on which the request was received.


Server represents server
Remote represents client

What about Local?


SCJP 5 |SCWCD 5| Started thinking about Web Services ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
Why not write a simple servlet and print those values to the console? That should provide an answer in minutes.


Ping & DNS - my free Android networking tools app
Sandeep Bhandari
Ranch Hand

Joined: Apr 16, 2004
Posts: 201
The hint is that server assigns a different port for communication once it has accepted the connection.

e.g.
A service is listening on port 100 and it accepts a connection from a user. Now further data transfer may be made through port 110 as 100 is used for listening to other users' request (you don't want a server that serves single user at a time)

Now read the servlet specification for more clarity on what does local represent.


SCJP 96% | SCWCD 90%| SCJP mock exams | My SCJP blog
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Thanks Sandeep Bhandari
Arunkumar Durairaj
Greenhorn

Joined: Jun 01, 2008
Posts: 4
hi,
Local and server both are technically same,but differ logically in the function it does.Both of them are remote to client as said earlier.Addressing your query,Server may be thought of possessing many logical ports.Local here represents the port on which requested service is provided .On the other hand server port receives the incoming request but doesn't provides any response in reply to request !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServlerRequest Methods