• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

ServlerRequest Methods  RSS feed

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • 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: 42975
76
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks Sandeep Bhandari
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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 !
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!