how can i write a code which counts to me number of visits a user had to site, and total number of visits to that site from all users.

here is code i have written

count.jsp

<%@page import="dayexercises.counter"%>

<jsp:useBean id="acounter" class="dayexercises.counter" scope="session" />

<jsp:setProperty name="acounter" property="*"/> 



<jsp:useBean id="acounter1" class="dayexercises.counter" scope="application" />
<jsp:setProperty name="acounter1" property="*"/>


<%
out.println("Number of visits session");
acounter.increaseCount();
out.println(acounter.getCount());
out.println("Number of visits application");

acounter1.increaseCount();

int y =acounter1.getCount();
out.println(y);

%>

and counter.java

package dayexercises;


public class counter {
	int count;

	public int getCount() {
		return count;	
	}

	public void increaseCount() {
		count++;
	}
}

session is working, but application isnt working. when i open page it counts.. then after i close, the application is supposed to keep all counts but its not working. solutions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.