开发者

JSP: Getting viewer's IP

开发者 https://www.devze.com 2023-01-30 22:04 出处:网络
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

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

精彩评论

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