Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2002-04-21
8
Medium Priority
?
189 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
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses

783 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