obtain url on server side ?

mach3_1986
Kilo Contributor

Hello,

Is there a way you can obtain the current url on server side ? (in a script include file)
Something that would retrieve something like "demo006.service-now.com/incident/weirdurl.do?param1=1".

I can't seem to find any solution to this. Any suggestion is welcomed.

Thx in advance for your help.

8 REPLIES 8

mach3_1986
Kilo Contributor

Hello Abhiram,

Thx for your answer. Your solution would work good in a normal behavior when session is already established.
In my case, what i am looking for is to obtain the requested url before the session has been established.

More details: The script include DetermineMobileDevice runs before session is established. I am trying a custom mobile device detection but i need the requested url.

Is there a way to obtain this in that script ?


mach3_1986
Kilo Contributor

Hi all,

I found a way to do it after all.

Again, the scope. I wanted to customize the DetermineMobileDevice script in order to return true/false based on user_agent + url (specifically, the CMS site name accessed).

What i found out is that:

- DetermineMobileDevice runs once, before session is established and befor esetting cookies on the client.
- My CMS sites are login form based, thus, before user is authenticated, the entry page is always the site login page.
- I can use the gs.action.getGlideURI() in the DetermineMobileDevice script that will retrieve something like: "view_content.do?/=&sysparm_is_login=true&sysparm_stack=no&sysparm_sys_id=GUID"
- GUID is always the sys_id of the login page of the site.

This allows me to customize the script based on these sys_id of each login page.

Not sure, again, if it is the best way. But it is how i managed to work around it...

Thx for your suggestions.
Alin


Hi, in case that it helps to others that reference this thread due to it's title. The URL processed on the server side can be retrieved by doing something like the following:



gs.getProperty("glide.servlet.uri") + gs.action.getGlideURI()


Thanks,


Berny


Sharique Azim
Kilo Sage

I think there is a change in methods.

 

Please now  use gs.getSession().getUrlOnStack(); instead(Kingston).