Retrieve the host name and port of the server, to use it as a link in the body of an email

1

I have a web application that is built using servlets, and I have a bean that is in charge of sending emails, and in these a link is added to enter a certain part of the system

 .append(servidor+"sisalbmReporte/grupos?action=vulnerabilidades&id=")

But I was handling the server parameter in the following way:

private static final String servidor= "http://170.70.141.252:8080/

But my application is going to go up to production and the server area tells me that they handle clusters, so that server statement will create conflicts, in which way I can send the name of the server and the port invariably of the team where I am.

I had read something about HttpServletRequest:

 HttpServletRequest request;
 String serverName = request.getServerName();
 int portNumber = request.getServerPort();

But NullPointerException marks me I do not know what I can do

    
asked by J. Cristian 17.03.2017 в 20:18
source

0 answers