Home
Analytics
How to get client IP Address
yrraja
Hi All
I have a requirement to show the IP address of the user on the report. Is it possible to get the IP address and display it in BIRT report?
Thanks
Y
Find more posts tagged with
Comments
Yaytay
BIRT desn't know anything about your client, as far as the report engine is concerned there may not even be a web client, so the answer you are looking for depends on how you have deployed the report engine.
If you let us know how you are running the report there may be a way to access the client address.
Jim
yrraja
Thanks Jim for the reply.
I am using the BIRT sample viewer 3.7.2 deployed on Tomcat server.
Y
Yaytay
<blockquote class='ipsBlockquote' data-author="'yrraja'" data-cid="109045" data-time="1346701732" data-date="03 September 2012 - 12:48 PM"><p>
Thanks Jim for the reply.<br />
<br />
I am using the BIRT sample viewer 3.7.2 deployed on Tomcat server.<br />
<br />
Y<br /></p></blockquote>
The I <em class='bbc'>think</em> this will work:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var request = reportContext.getHttpServletRequest();
var requestFieldMap = new Packages.java.util.Hashtable();
requestFieldMap.put( "RemoteAddr", request.getRemoteAddr() );
requestFieldMap.put( "RemoteHost", request.getRemoteHost() );
</pre>
<br />
The attached file demonstrates this by dumping a load of contextual information - even if it doesn't get you what you need it might give you a point in the right direction.<br />
<br />
Note that I haven't actually tested this with the viewer in Tomcat
<br />
<br />
Jim
bgbaird
Yaytay, nice example, thanks!
yrraja
Jim, Thanks a lot.
I do see that the required information is being dumped in this report. This example is very helpful.
Y
Yaytay
I just put a better version of this report onto devshare:<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1540-obtaining-contextual-information-from-a-report-server'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1540-obtaining-contextual-information-from-a-report-server</a><br
/>
<br />
Jim