Total members 9936 | Gratitudes |It is currently Sun Feb 05, 2012 8:06 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 5 posts ] 
Author Code Snippet
 Code subject: jsp page counter
PostPosted: Sun Jan 11, 2009 1:36 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2101
Location: Earth
Has thanked: 39 time
Have thanks: 56 time

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

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Code subject: Re: jsp page counter
PostPosted: Wed Mar 25, 2009 4:17 am 
Offline
Newbie
User avatar

Joined: Thu Mar 19, 2009 3:28 pm
Posts: 6
Has thanked: 0 time
Have thanks: 0 time
Thanks for providing jsp page counter. Btw, i have to ask you what <% means ?


TOP
 Profile Send private message  
Reply with quote  
 Code subject: Re: jsp page counter
PostPosted: Fri Apr 24, 2009 8:23 pm 
Offline
Newbie
User avatar

Joined: Fri Apr 24, 2009 8:17 pm
Posts: 2
Location: Colorado Springs, CO USA
Has thanked: 0 time
Have thanks: 0 time
The tag <% means that the following code is Java. The %> ends the java code and goes back to html.


TOP
 Profile Send private message  
Reply with quote  
 Code subject: Re: jsp page counter
PostPosted: Sun Oct 04, 2009 10:13 am 
Offline
Newbie
User avatar

Joined: Sun Oct 04, 2009 10:10 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
Just curious where does the counter store the number of hits ???


Thanks/


TOP
 Profile Send private message  
Reply with quote  
 Code subject: Re: jsp page counter
PostPosted: Sun Oct 04, 2009 11:11 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2101
Location: Earth
Has thanked: 39 time
Have thanks: 56 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 .

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 5 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 change the direction of text in your page  HTML examples  msi_333  0
 middle sited body page  HTML examples  msi_333  0
 link to parts in the same page  HTML examples  msi_333  0
 get current page link  JavaScript examples  msi_333  0
 redirect to another page  JavaScript examples  msi_333  0

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team