开发者

JSP: Getting viewer's IP

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 mon开发者_JAVA百科itor what part of my project are they viewing.

Thanks, Cyril H.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜