File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

How to find server name

Eivind Rasmussen
Greenhorn

Joined: Dec 05, 2003
Posts: 8
Hi,
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="http://webtools.servehttp.com" target="_blank" rel="nofollow">http://webtools.servehttp.com</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
Greenhorn

Joined: Apr 23, 2004
Posts: 11
try this
request.getServerName();


satya
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
Greenhorn

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


- Alex Danesi - SCJP 1.4
Vishwa Bandhu
Greenhorn

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: 16019
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find server name