It is currently Fri Jul 30, 2010 1:54 pm


All times are UTC [ DST ]


Ask on Codemiles community and get answers Free and Fast :

JSP Code Examples

Our guest share with us your code snippets , your programming problems , your open source projects ,read articles and post yours .







Post new topic Reply to topic  [ 5 posts ] 
  Print view Previous topic | Next topic 
Author Message
 Post 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: 1573
Location: Earth
Has thanked: 10 time
Have thanks: 16 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 .


TOP
 Profile Send private message  
 
| More
 Post 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  
 
| More
 Post 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  
 
| More
 Post 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  
 
| More
 Post 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: 1573
Location: Earth
Has thanked: 10 time
Have thanks: 16 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 .


TOP
 Profile Send private message  
 
| More
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


 Similar topics
 Topic title   Forum   Author   Replies 
 Crystal report export to excel, page header issue asp.net  ASP.NET  MFiaz  0
 Cant change the culture or UICulture of the content page  ASP.NET  yaniv  2
 A simple search page using Google AJAX Search API  AJAX  Casper  1
 Call PHP code from JSP Page  Servlets / JSP  sangravi  0
 Only the data needs to be updated and not the whole JSP page  AJAX  skyit123  3

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  





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-2009
mileX v1.0 designed by codemiles team