NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Poul Jensen on April 14, 2025, 08:39:08 PM

Title: Pass parameter in servercall? (RESOLVED)
Post by: Poul Jensen on April 14, 2025, 08:39:08 PM
Hi,

I would like to pass a parameter to the NT server like this:
https://myntserver.com?a=x

And then read the value x into a session value in the webserver procedure.

How do I do this?

tia
/Poul
Title: Re: Pass parameter in servercall?
Post by: Niels Larsen on April 14, 2025, 09:37:01 PM
p_web.GetValue('a')


Title: Re: Pass parameter in servercall?
Post by: Poul Jensen on April 14, 2025, 09:57:53 PM
Tak Niels.
Title: Re: Pass parameter in servercall?
Post by: Niels Larsen on April 14, 2025, 11:48:55 PM
Altid :-)
Title: Re: Pass parameter in servercall?
Post by: Poul Jensen on April 15, 2025, 06:53:16 AM
What is the earliest point in the app, where I should read the parameter, preferably code that is reached once only per user?

/Poul
Title: Re: Pass parameter in servercall?
Post by: Poul Jensen on April 15, 2025, 08:21:01 AM
Let me expand on this:

What I want to achieve, is to call the app with a parameter, read this parameter and change the filenames global variable names, so they point to a specific dataset.
As per the docs re Multiple Data Sets:  https://www.capesoft.com/docs/NetTalk14/NetTalkWebBasic.htm#MultipleDataSets, I have tried the webhandler RequestHostSet embed to read the parameter and save it in a session variable.

But next time through the webhandler this is being reset.

So I need some guidance here for the best approach.

tia

/Poul
Title: Re: Pass parameter in servercall?
Post by: Alberto on April 15, 2025, 11:46:01 AM
Use the ProcessLink() WebHandled Method, there you can change the database.
Cheers
Title: Re: Pass parameter in servercall?
Post by: Poul Jensen on April 15, 2025, 10:43:24 PM
Hi Alberto,

That is what I am using, but at soon as I click the button for the login window, the filename variables are being reset.

Cheers
/Poul
Title: Re: Pass parameter in servercall?
Post by: Jane on April 16, 2025, 03:22:59 PM
Works for me, Poul.
How are you storing the parameter?  If you're putting it into a sessionValue, it should be sticky and persist through the login and beyond.

You'll need to set your filename variables EACH TIME your code runs through p_web.ProcessLink in the webhandler (because each pass through there is happening on a new thread), so set the session values the first time (when they're sent as parameters) then use those session values to set the filename variables EACH TIME.
Title: Re: Pass parameter in servercall?
Post by: Bruce on April 16, 2025, 06:45:26 PM
p_web.StoreValue('a')
Is the best way to set a session value to a value, because then if the value doesn't exist (as a parameter) it does not overwrite the session value.
I expect you are just overwriting your session value to blank when the value does not exist.
Title: Re: Pass parameter in servercall?
Post by: Poul Jensen on April 17, 2025, 12:32:03 AM
You'll need to set your filename variables EACH TIME your code runs through p_web.ProcessLink in the webhandler (because each pass through there is happening on a new thread), so set the session values the first time (when they're sent as parameters) then use those session values to set the filename variables EACH TIME.

That was the missing piece :-)

Thanks Jane.
Title: Re: Pass parameter in servercall?
Post by: Poul Jensen on April 17, 2025, 12:32:39 AM
p_web.StoreValue('a')
Is the best way to set a session value to a value, because then if the value doesn't exist (as a parameter) it does not overwrite the session value.
I expect you are just overwriting your session value to blank when the value does not exist.

Thanks Bruce - spot on.