Get full URL on a TiNG client

Forum to discuss the new web client version of Servoy.

Get full URL on a TiNG client

Postby rph » Mon Nov 04, 2024 12:05 pm

Hi

Is there a way to get the full URL from a TiNG-Client? application.getServerURL() only gives for example "http://localhost:8297/" without the rest like context, solutionname and stuff like that. Even if in the documentation there is written "For a NGClient this will be the url that the user sees in the browser url bar.
For Headless pure server based clients this will just be http://localhost[:port]"!

Or is there another way to get the context? We need to know the context because we have sometimes multiple installation (prod-, demo-, test) on the same application-server and depending on that we do stuff. So the url differs only in the way like "https://www.xyz.com/myapp-test/solution/..." and "https://www.xyz.com/myapp-demo/solution/..." and "https://www.xyz.com/myapp-prod/solution/..."

Best
Roland

Servoy version 2024.3.3 -releaseNumber 3946 (builddate: 2024-07-19 11:26)
rph
 
Posts: 94
Joined: Wed Aug 10, 2011 11:44 am
Location: Cham, Switzerland

Re: Get full URL on a TiNG client

Postby patrick » Mon Nov 04, 2024 12:41 pm

The context in which the app server is running will be included in application.getServerURL(). So the full URL can be calculated as

Code: Select all
application.getServerURL() + 'solution/' + application.getSolutionName() + '/index.html';
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3709
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Get full URL on a TiNG client

Postby rph » Mon Nov 04, 2024 7:26 pm

Hi Patrick

Thanks for your reply.

Obiously I misunderstood the tooltip of the function "application.getServerURL". I assumed that it will return the full URL and then I created a regular expression to extract the context out of the URL. But because "application.getServerURL" only returns the first part of the URL (the server address plus the context) my regular expression failed. And on a developer you couldn't really test these things, because you never have a "context" in developer.

I fixed my regular expression now and deployed it on a testsystem and now it delivers the context as I expected it.

Thanks again.
Roland
rph
 
Posts: 94
Joined: Wed Aug 10, 2011 11:44 am
Location: Cham, Switzerland


Return to Servoy NGClient

Who is online

Users browsing this forum: Bing [Bot] and 4 guests