Switch to full style
JSP Code Examples
Post a reply

jsp page counter

Sun Jan 11, 2009 1:36 am

jsp page counter code
Code:
<HTML>
    <
HEAD>
        <
TITLE>JSP page Counter</TITLE>
    </
HEAD>

    <
BODY>
        <
H1>JSP page Counter</H1>
        <%
    

        
Integer applicationCount = (Integer)application.getAttribute("applicationCount");
        if (
applicationCount == null) {
            
applicationCount = new Integer(1);
        } else {
            
applicationCount= new Integer(applicationCount.intValue() + 1);
        }

        
application.setAttribute("applicationCount"applicationCount);
        %>

        
        <
BR>
        
Visitors to this page so far <%=applicationCount%> (visitor).
    </
BODY>
</
HTML




Re: jsp page counter

Wed Mar 25, 2009 4:17 am

Thanks for providing jsp page counter. Btw, i have to ask you what <% means ?

Re: jsp page counter

Fri Apr 24, 2009 8:23 pm

The tag <% means that the following code is Java. The %> ends the java code and goes back to html.

Re: jsp page counter

Sun Oct 04, 2009 10:13 am

Just curious where does the counter store the number of hits ???


Thanks/

Re: jsp page counter

Sun Oct 04, 2009 11:11 am

Using the application object we use the getAttribute and setAttribute to save variables .Here the variable named "applicationCount" .

application object control attributes with the scope all over your JSP application .

There are also other known objects like (session) object , which often used to save parameter while login process .

Post a reply
  Related Posts  to : jsp page counter
 File page counter in php     -  
 Use cookie to create page counter     -  
 Use cookie to create page counter     -  
 Image Scroller-scrollbar-LINE_UP,LINE_DOWN-PAGE-UP-PAGE-DOWN     -  
 Writing a Counter to any PORT     -  
 reset the list counter     -  
 ramp Counter ANALOGUE TO DIGITAL CONVERSION (ADC)     -  
 old NASA style counter built from Swing components     -  
 How to add CSS to a web page     -  
 redirect to another page     -  

Topic Tags

Servlets/JSP