Solved

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

Posted on 2002-04-21
8
181 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
8 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
> i tried InetAddress but its giving me the clients IP.

WHere were you running your code?
0
 

Author Comment

by:snehalkgandhi
Comment Utility
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
Comment Utility
request.getHeader("host") should return the info you want
0
 
LVL 7

Expert Comment

by:Igor Bazarny
Comment Utility
Did you try InetAddress.getLocalHost()?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
0
 
LVL 3

Expert Comment

by:shyamkumarreddy
Comment Utility
snehalkgandhi

Pls use HTML Headers to fetch the Server IPAddress.

Shyam
0
 

Accepted Solution

by:
skg_bfn earned 100 total points
Comment Utility
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
Comment Utility
thanks
SKG
 it was working perfectly.

Snehal
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now