• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ServlerRequest Methods

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not write a simple servlet and print those values to the console? That should provide an answer in minutes.
 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sandeep Bhandari
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !
 
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic