Skip to main content

Command Palette

Search for a command to run...

Oracle Portal Client IP Address (REMOTE_ADDR)

Updated
2 min read

You may want to show the IP address of the client (the browser) on a Portal page. This can be tough because the page is built by the parallel page engine (PPE). At that point, the actual requestor is the mid-tier itself. You need to make a call that goes all the way to the database without being redirected through the PPE. I do this by creating a pl/sql procedure (ideally part of a package) that I then call from a bit of javascript in the page (possibly through a UI Temple / HTML Template). Note: if the user is going through a proxy you will get the proxy IP. If you have a reverse proxy setup (e.g. multiple Oracle Web Caches or Apache Reverse Proxy) you can set things up to get the correct browser IP. See my other post on setting up chained Web Caches.

Here is the procedure, it's fairly straightforward.

CREATE OR REPLACE procedure c2_getClientIP is
l_ip varchar2(200);
begin
l_ip := owa_util.get_cgi_env('REMOTE_ADDR');
htp.p(l_ip);
end;
/

grant execute on c2_getClientIP to public;

Then you put a little javascript in the page to call that procedure.


word:

You can put the javascript in a template or as a text item. You can modify this however you want to either just show the IP, put in a variable, etc.