0

The following code displays no of visits on jsp page when visitors visit the page. Here counter is increased by a fixed number i.e.by one (+1). How can i increase the no. of visits randomly lets say by 10 , 15, 18 etc. each time the page gets refreshed ?

JSP----------------------

    Integer hitsCount = (Integer)application.getAttribute("hitCounter");
                if( hitsCount ==null || hitsCount == 0 )
                {
                    /* First visit */
                    hitsCount = 1;
                }
                else
                {
                    /* return visit */
                    hitsCount += 1; // Here I want that hitsCount to be 
 increased by random number lets say by +=10, +=15, +=18 etc each time the 
 page gets refreshed
                }
                application.setAttribute("hitCounter", hitsCount);
         out.println(hitsCount);// shows total no of visits
Tom
  • 761
  • 7
  • 22
  • 41

0 Answers0