기타
사이트 방문자 수 측정하기
현호s
2020. 8. 15. 15:48
반응형
# 사이트 방문자 수 측정
## 방법 1 (Application 객체 사용)
단, 새로고침 진행 시 꾸준히 늘어남...
<%@ page contentType="text/html;charset=euc-kr" session="true"%>
<%
if (application.getAttribute("Counter") != null) {
String strCounter = String.valueOf(application.getAttribute("Counter"));
int counter = Integer.parseInt(strCounter) + 1;
application.setAttribute("Counter", counter);
} else {
application.setAttribute("Counter", 1);
}
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
방문자 수 : <%=application.getAttribute("Counter")%>
</BODY>
</HTML>
반응형