cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the J2EE server hostname and port programmatically

larry_forrest
Discoverer
0 Kudos

Is there any API to read the J2EE server host and port programmatically? I am looking for the hostname where the components are deployed so that I can append the wsdl path to the server and create an URL.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185706
Participant
0 Kudos

Hi Larry,

there is a standard J2EE Servlet API for your case.

In a servlet or jsp file you can get the host and prot from the request object.

For example in a JSP file :

request.getScheme();
  request.getServerName()
    request.getServerPort()

You can check the whole API here :

http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletRequest.html#getServerName()

Bets Regards

Bojidar