0

i want to read Url from web Browser (Vaadin 7) my Server support sub domain , Url format : subdomain.applicationName.com example : private.myapp.com , public.myapp.com

i use the method Page.getCurrent().getLocation() to read Url from Web browser but the returned value is

http://32.186.55.179/myapp ==> i dont know why server return Ip adreess instead the domain Name

i want a way to read the value of sub domain entered in the Url

example : Url browser http://private.myapp.com => result =private.myapp

Yassine
  • 1
  • 1
  • In the example you provided you can do something like: `System.out.println(myUrl.substring(0,hello.lastIndexOf(".")));` which gives you: `http://private.myapp` – Brunaldo Feb 13 '15 at 14:06
  • thank you Brunaldo for your response but my problem is how to get the url from browser adress bar to extract sub domain , when i invoke HttpServletRequest.getServerName() it always returns the ip instead of subDomaine Name (String) – Yassine Feb 13 '15 at 14:19
  • Maybe this can help you: http://stackoverflow.com/a/5648259/4535117 – Brunaldo Feb 13 '15 at 14:22
  • thank for your interest i tried all those methods but they return always the same results ip adress when the url contains a sub domain . – Yassine Feb 13 '15 at 15:02
  • Have you tried doing a reverse lookup? `String hostname = InetAddress.getByName(ip).getCanonicalHostName();` – bekce Mar 05 '15 at 13:03

0 Answers0