| Author |
Regarding method getLocalPort()
|
Jay Shukla
Ranch Hand
Joined: Jun 08, 2008
Posts: 214
|
|
Hi i came to know about getLocalPort() method that I took help from "Head First Servlet and JSP" but didn't work out. getLocalPort() ---> It says "on which port did the request END UP?" What is the meaning of statement in above quotes?? Please explain in brief. Thanks in Advance.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
"Jay", please check your private messages for an important administrative matter. Again.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Originally posted by Jay: Hi i came to know about getLocalPort() method that I took help from "Head First Servlet and JSP" but didn't work out.
why? anyways it gives your server port number for example: http://localhost:8081/webA/controller then in controller request.getLocalPort() gives you 8081 Hope This Helps
|
 |
Jay Shukla
Ranch Hand
Joined: Jun 08, 2008
Posts: 214
|
|
Hi Bear i think now thw name (Jay Shukla) looks fine to you. And the method getLocalPort() is from ServletRequest Interface. Any help greatly appreciated. Thanks, Jay.
|
 |
Jay Shukla
Ranch Hand
Joined: Jun 08, 2008
Posts: 214
|
|
Thanks Sreetharaman for the reple. But in the book (Head First...) They explain subtle differece between getServerPort() and getLocalPort() (both from ServletRequest Interface). For the first method (getServerPort()) - "to which port was request originally SENT?". As per the Head First ..." "But there's differnce because although requests are sent to single port(Where the server is listning), the server turns aound and finds a different port for each thread so that the app can handle multiple clients at the same time". In above quote if request was sent to one perticluar port than how server will able to listen that perticular request if it tries to find differnt port?? Thanks. Jay.
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2562
|
|
Not really. request.getServerPort() will give 8081 Although request.getLocalPort() will give you 8081 sometimes but not all the time. Hope this helps
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Thanks Amit Ghorpade
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2562
|
|
Originally posted by seetharaman venkatasamy: Thanks Amit Ghorpade
You are welcome
|
 |
 |
|
|
subject: Regarding method getLocalPort()
|
|
|