0

I have a question regarding the embedding of a GWT application.

The problem concerns getting the address of the client, and match it to the ip in the tag's src attribute. So the structure is Host html page (hosted on server a), embedding a gwt application hosted on server b.

    <!DOCTYPE HTML>
<html dir="ltr" lang="en-US">
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

   <title>Embedding gwt app</title>
   <script type="text/javascript" src="http://192.168.0.1:8080/myapp/myapp.nocache.js?rootpanel=divone"></script>
 </head>
 <body>
    <div id="divone" style="width:100px;height:100px;"></div>   
 </body>
</html>

What we have tried before is get the host path by using GWT.getHostPageBaseURL(), but this returns the host page's ip (we expected this..)

Are we trying to achieve something impossible? considering that the script file gets downloaded first, and then the onModuleLoad gets called when the script is ready on the client.

Joey Roosing
  • 2,145
  • 5
  • 25
  • 42
  • It's not clear what you are asking. Are you trying to check the IP address of a user? And why do you put the local host IP in your host page code? – Andrei Volgin Mar 12 '14 at 14:13
  • Good point. It should be any other ip. As to what I want; I want the IP of the origin from where the guest(gwt) application is downloaded from. and compare it to the tag's src attribute(the host part) – Joey Roosing Mar 23 '14 at 15:31

1 Answers1

0

You can make a RPC request to the server side, and the server can do the following to get the client's IP: getThreadLocalRequest().getRemoteAddr();

Or if you don't want to make a request and want to do the work on the client side, you can make a GWT native JS method and try one of the suggestions from this stackoverflow post: How to get client's IP address using javascript only?

Community
  • 1
  • 1
Churro
  • 4,166
  • 3
  • 25
  • 26