0

Greetings,

I am using Apache Tomcat 6.0 using Windows 7 Professional as my OS. I have developed a JavaEE project using Netbeans 6.9.1 I have a domain on Dyndns that goes directly to the Apache Tomcat 6.0.

I was wondering if this is possible? I want to track/monitor the IP (IPv4 / IPv6) which are currently viewing my domain. Also, can I also monitor what part of my project are they viewing.

Thanks, Cyril H.

Cyril Horad
  • 1,555
  • 3
  • 23
  • 35

1 Answers1

1

To view the the current query string you can use:

((HttpServletRequest)request).getQueryString();
((HttpServletRequest)request).getRequestURL();

from there you could extract the current part of your project.

To get the remote IP/host:

request.getRemoteAddr();
request.getRemoteHost();

You can use both in your jsps, servlets or filters.

morja
  • 8,297
  • 2
  • 39
  • 59
  • Using the said information, Can I send these information on a JavaSE server I have programmed? This would help me monitor the traffic/session counter on a page. – Cyril Horad Dec 15 '10 at 12:17
  • Well in general yes. You can send any information to another server. How to do this depends on many things: your server, your project setup and so on... but usually you would use messaging, use a shared database or make a socket call to your server. – morja Dec 15 '10 at 12:27
  • In this manner, can I also trace if the IP is still viewing my domain? – Cyril Horad Dec 15 '10 at 14:03
  • Well, you can make a session and keep track of the IP in it, if the session times out its likely that the remote client is no longer accessing your site. To be sure you would have to make a javascript that checks if the client is still accessing your site. – morja Dec 15 '10 at 14:42
  • Ok, is there a way to look into the stateless sessions which contains the 2 data? – Cyril Horad Dec 16 '10 at 19:56
  • No, you would have to store the information in the session at some point. – morja Dec 16 '10 at 19:59