How to get the Vaadin 7 application server IP and port?

Jorge Infante Osorio picture Jorge Infante Osorio · Feb 14, 2014 · Viewed 6.9k times · Source

How can I get the protocol, IP and port of the app server running my Vaadin webapp? I'm using Vaadin 7.

In vaadin 6 I doing in this way, but not work in vaadin 7:

String server = ((WebApplicationContext) this.getContext()).getHttpSession().getServletContext().getServerInfo();

java.net.URL url = this.getURL();
String s = url.getHost()+":"+url.getPort()+url.getPath();

Answer

Vikrant Thakur picture Vikrant Thakur · Feb 19, 2014
System.out.println(UI.getCurrent().getPage().getLocation().getHost());
System.out.println(UI.getCurrent().getPage().getLocation().getPath());
System.out.println(UI.getCurrent().getPage().getLocation().getPort());