How To Find Users Ip Address In Oracle Apex Application?
Those Of Us Who Work With Oracle Apex Applications, Have To Use JavaScript Code From Time To Time. I Will Try To Show The Use And Code Of JavaScript From Beginner Level To Pro Level In Oracle Apex Application, I Will Discuss All JavaScript Code In My Below Application Using JavaScript, Hope All Parts Of My JavaScript Will Be Useful For Any Apex Developer, Request To See All Video Parts And Posts.
I Will Try To Show How To Extract Local Ip, Public Ip, Real Ip Of Users In Oracle Apex Application And Put It In Item.
To get the local IP, take a new item as before, name-P1_IP,
I Will Select The Following Options From The Default Option Of The Item
Type=Expression
Language=PL/SQL
PL/SQL Expression -
wa_util.get_cgi_env('REMOTE_ADDR')
I Will Run The Page.
To get the public IP, take a new item as before, name-P1_PUBLIC_IP,
Click Execute When Page Loads At The Top Of The Page, I'll Go To Options And Use The JavaScript Code Below.
$.getJSON("https://api.ipify.org?format=json", function(data) {
// Setting text of element P with id gfg $s("P1_PUBLIC_IP",data.ip); })
I Will Run The Page.
To Find Out The Real Ip Of The User, Take A New Item As Before, Name- P1_REAL_IP
I Will Select The Following Options From The Default Option Of The Item
Type=SQL Query returning Colon Delimited List
SQL Query Colon-
SELECT OWA_UTIL.GET_CGI_ENV ('X-FORWARDED-FOR') REAL_IP FROM DUAL
I Will Run The Page.
To Find Out The Sys_context Ip Of The User, Take A New Item As Before, Name- P1_SYSCONTEXT
I Will Select The Following Options From The Default Option Of The Item,
Type=Expression
Language=PL/SQL
PL/SQL Expression=
SYS_CONTEXT ('USERENV', 'IP_ADDRESS')
I Will Run The Page.