amar on web

Retrieving Client pc information on the web

This note aims at providing solution for getting the end-user pc client details on web, it is applicable for Forms 6i and above releases deployed on web. Most of the existing Oracle routines/views are designed to return client information when run in client/server mode. When run on web (with iAS server between the database and client), these routines/views return the property of the web server. For instance, the machine name in V$SESSION view will be the web server machine name and not the actual client machine. This is the right behaviour for the routines and views as logic can now be designed for the midtier.
Some applications do rely on information about the client to carry out some business requirement. This may be required to code logic that take the following into account. Such logic may not work when migrating from client/server to web.

- the machine name (host) from where the application is accessed
- the operating system login id
- the IP address of the client machines
- the operating system of the client machine and/or its version
- client timestamp

I checked on some options floating around to get client information in forms on web. One option I tested was using getclientinfo.jar file provided by Oracle. Jar files can be called in forms using Java beans. You can download this jar from OTN site. The forms demo pack elaborates on the usage of this jar file. I have provided a simplified version of making the call without much plug-ins.

1. Web server setup

Download the getclientinfo.jar file from OTN web site (the required classes are also present in the webutil.jar file, incase you are already using this). Copy the Jar file in $ORACLE_HOME/forms90/java folder. Modify the tag in formsweb.cfg file to include this jar file in the below parameter.

2. Coding in forms

a) Create a form (or change existing one) to include the following items-
- A canvas named "clientcan".
- A block named "clientinfo".
- Add a bean area item named "clientbean" in the clientinfo block. Set the visible canvas to "clientcan".

b) Add the following code to register the bean in WHEN-NEW-FORMS-INSTANCE trigger.
  FBean.register_bean('clientinfo.clientbean', 1, 'oracle.forms.demos.beans.GetClientInfo'); 
c) Add the following code in the required place where the client information is to be retrieved. Routine FBean.invoke_char is called to get the values.

  l_var    varchar2(200); 
  -- use one or more of the below calls to get client information and use accordingly. 
  l_var := sys_context('userenv', 'session_user');
                                  -- oracle username(can also use user, userenv)
  l_var := FBean.invoke_char('clientinfo.clientbean',1,'getUsername');
                                  -- operating system username    
  l_var := FBean.invoke_char('clientinfo.clientbean',1,'getHostname');
                                  -- machine/hostname 
  l_var := FBean.invoke_char('clientinfo.clientbean',1,'getIPAddress');
                                  -- client PC ip address 
  l_var:= FBean.invoke_char('clientinfo.clientbean',1,'getDate');
                                  -- date on the client machine 
  l_var := FBean.invoke_char('clientinfo.clientbean',1,'getSystemProperty','java.version');
                                  -- Jinitiator version 
  l_var := FBean.invoke_char('clientinfo.clientbean',1,'getSystemProperty',''); 
                                  -- operating system name 
  l_var := FBean.invoke_char('clientinfo.clientbean',1,'getSystemProperty','os.version');
                                  -- operating system version 
I added a display item to my test form with the above code. A screenshot of my test form is available below.
client info screenshot

Best viewed in medium text size. Please refresh this page (F5) to view the latest information.
This page was created on 02-feb-2007 and last updated on 02-feb-2007.
please forward all queries to [email protected]