jdbc:mysql://localhost/test org.gjt.mm.mysql.Driver <%-- insert a row into the database --%> insert counters(page,hitCount) values('<%=request.getRequestURI()%>', 0) <%-- the insert may fail, but the page will continue --%> <%-- update the hit counter --%> update counters set hitCount = hitCount + 1 where page like '<%=request.getRequestURI()%>' <%-- execute the query --%>
This page has been hit <%-- query the hit counter --%> select hitCount from counters where page like '<%=request.getRequestURI()%>' <%-- process only the first row of the query --%> times. The page counter is implemented using the Jakarta Project's DBTags tag library, calling JDBC indirectly.