Solved

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

Posted on 2002-04-21
8
187 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Industry Leaders: 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

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.
Suggested Courses

624 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