Solved

how to get the Ip and Port number of the server using servlets

Posted on 2002-04-21
8
186 Views
Last Modified: 2013-11-24
hi
how to get the IP address and port number of the Server using servlets.i'm using tomcat 4.0.1 on linux 7.1. i need to get this IP and port. i tried InetAddress but its giving me the clients IP. its urgent.
regards
snehal
0
Comment
Question by:snehalkgandhi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6959079
> i tried InetAddress but its giving me the clients IP.

WHere were you running your code?
0
 

Author Comment

by:snehalkgandhi
ID: 6959092
i just tried it out in my system. and the tomcat is also running on my system. and when i tried it from another system i was getting that particular's systems default IP address
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6959463
request.getHeader("host") should return the info you want
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6960203
Did you try InetAddress.getLocalHost()?
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6961418
0
 
LVL 3

Expert Comment

by:shyamkumarreddy
ID: 6961839
snehalkgandhi

Pls use HTML Headers to fetch the Server IPAddress.

Shyam
0
 

Accepted Solution

by:
skg_bfn earned 100 total points
ID: 6961938
hi
u can use
request.getRequestURL() (returns a String Buffer)
request.getServerName()
request.getSceheme()- returns whether it is "http" or "https" or "ftp"
request.getServerPort() - returns the port number

try this out

regards
SKG
0
 

Author Comment

by:snehalkgandhi
ID: 6961948
thanks
SKG
 it was working perfectly.

Snehal
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
web application structure 18 135
Why is enum singleton a better approach than static factory 3 66
passing enum to a method 4 50
Java ArrayList and if statement 2 55
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question