Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-04-21
8
Medium Priority
?
188 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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 400 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

670 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