Total members 11872 |It is currently Fri Jan 27, 2023 3:49 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

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



Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

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



Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time

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


Thanks/



Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

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 .


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 5 posts ] 

  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






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com