• Post Reply Bookmark Topic Watch Topic
  • New Topic

getRemotePort(), getLocalPort() methods

 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried finding out the client port number used in a servlet using getRemotePort() - gives a compilation error. Also, getLocalPort() doesnt seem to work while getServerPort() works. Am i missing something here ?

Env. Tomcat5.0.30/Win XP
 
John Wolf
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PNS,

I don't have any problems with it. I used it in a filter as a test. Can you include the code here?
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is the code that i had used - i override the service method in my servlet that extends HttpServlet.
The lines have been commented since it resulted in a compilation error otherwise.


Besides, what ever the action method other than POST i specify in my jsp page calling this servlet, the first log statement gives me an output of GET.Don't understand why it works this way.
 
John Wolf
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PNS,

I still don't get any errors. Are you using J2EE 1.4 implementation?
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!