I want to maintain onw count value over a Http browser. Example :
If browser once open and click on submit button make count as one. again click on button make count as two. and I want count should be less than two.
Consider a count is : private static int count & maxCount is : private int maxCount = 3 code:
protected void processRequest(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
session.setAttribute("count", ++count);
if(session.getAttribute("count") <= maxCount){
//proccess stuff
}else{
//give maxcount completed message
}
}
It will work fine when open a browser first time but if I open a browser in another window then it will showing me maxCount completed message
I recognize this count is a static variable and gets memory once and all But what can I do for this. I want this count value as again zero when I open in a another window of the browser?