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();
as for the application path part, to get the real application directory and not the browser request path, use VaadinServlet.getCurrent().getServletContext().getContextPath()
System.out.println(UI.getCurrent().getPage().getLocation().getHost());
System.out.println(UI.getCurrent().getPage().getLocation().getPath());
System.out.println(UI.getCurrent().getPage().getLocation().getPort());
I do it like this:
String basePath = Page.getCurrent().getLocation().getScheme() + ":" +
Page.getCurrent().getLocation().getSchemeSpecificPart()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With