File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How to find server name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to find server name" Watch "How to find server name" New topic

How to find server name

Eivind Rasmussen

Joined: Dec 05, 2003
Posts: 8
does anybody know how to find the server-name (in the code) of the server im running my java-program on. I've tried all the System-properties, but still cant fint the server-name.
Brahim Bakayoko
Ranch Hand

Joined: Aug 29, 2003
Posts: 155
Most servers set it in the response header. The header is called "Server".

SCJP, SCWCD, SCBCD, IBM CSD WebSphere v5, <br />A+, MCP 2000 and 2000 server, CST, and few incompleted certification tracks.<br /> <br />Ivory Coast<br /> <br />Analyze your web Request/Response @ <a href="" target="_blank" rel="nofollow"></a> down for a while...
danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
Use getServletName() method
Brahim Bakayoko
Ranch Hand

Joined: Aug 29, 2003
Posts: 155
Originally posted by danny liu:
Use getServletName() method

Server name, not Servlet name...
Satya Komirisetti

Joined: Apr 23, 2004
Posts: 11
try this

Brahim Bakayoko
Ranch Hand

Joined: Aug 29, 2003
Posts: 155
Eivind are you refering to the container server name or the host server name?
If host name: do as Satya said.
If container server name: look in the response header
Alessandro Danesi

Joined: May 03, 2004
Posts: 3
You can retrieve container server name as:
ServletContext ctx = session.getServletContext();

- Alex Danesi - SCJP 1.4
Vishwa Bandhu

Joined: Apr 29, 2004
Posts: 12
Is there any way to find out what is the WAN IP of the network from within the network? I mean, I am running a java program on my desktop, which is connected to a router, and can I find the Internet IP address for the network from the router...?
Thank you.
[ May 03, 2004: Message edited by: Chidananda Kakunje ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

You are assuming that all networks are simple ones. Mine aren't. They have multiple NICs attached to different LAN segments and may go out through different routers over differen WANs to different ISPs.
Actually, what good does knowing the WAN address do anyway? The WAN is just the pipe to the Internet at large.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: How to find server name
It's not a secret anymore!