3

I need to determine, what web server (IIS, Apache, Jetty) is running on port 80 in Java.

Are there any solutions to get the informations via port 80?

Thanx and reguards

Stefan

user30724
  • 215
  • 1
  • 2
  • 6

2 Answers2

6

You can ask it - issue a HEAD request, e.g. open a TCP connection on port 80 and just send

HEAD / HTTP/1.0

or

HEAD / HTTP/1.1
Host: the.server.hostname.com

and the reply should contain a Server line

Server: Microsoft-IIS/5.1

amongst other things.

If you want to ask the OS which process, though, I don't know a Java-portable way. Command line you would run netstat -ano or (-anp on linux I think) which will give you the process number listening on port 80, and then you can look that up to find out exactly which server has the port.

Rup
  • 31,518
  • 9
  • 83
  • 102
3

Look at the Server: HTTP header. It will usually contain something like this:

Server: Apache/2.2.10 (SpaceNet) PHP/5.2.6

Of course, the server can send whatever it likes, or not send anything at all.

Michael Borgwardt
  • 327,225
  • 74
  • 458
  • 699