How To Find Users Ip Address In Oracle Apex Application, JavaScript In Oracle Apex App, Part-1

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.

1. First we will see how to find the local IP.
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.

2. Now we will find out the user's public IP.
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.

3. Now we will find out the real IP of the user,
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.

4. Finally We Will Extract The User's SYS_CONTEXT IP
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.

Post a Comment

Hlo Sir

Previous Post Next Post