Hit counter in jsp

hi
i want to know that how can we implement hit counter in our jsp page
i want 2 hit counter
1-total number of hits on page
2-total number of online members at that time
send me soon

i have a list of links(which are links to other web applications which i didn't make and can't access) in my jsp retrieved from a table in my database which stores the link name and the number of hits and in their <a href> tag, i redirect them to another jsp, say for example, count.jsp
in my count.jsp, i get the index of the link i clicked and pass it to my java bean which in turn queries for the url of the link and passes it back to my count.jsp. i laso query for the existing number of hits from the table in the db which is set to 0 by default and also pass it back to my count.jsp
in my count.jsp, i increment the number of hits by 1 and pass it back to the bean to update the database.
while this is done, i redirect the count.jsp to the url i retrieved from my bean.
this could be different if your links are readily accessible and editable by you. you could just add a scriptlet in that link that increments the number of hits in your database.
i hope you got my point and i hope i helped....

Similar Messages

  • Hit counter on JSP page

    Hello java-ites,
    I want to create a counter on jsp page. How do I do it?
    Any help is appreciated.
    Many thanks.
    -Arun Chellapa.

    The way that I have used it as I have a myCounter.txt file that stores the last generated value and is stored.
    Make one JSP page with the sample code as
         long counter = 0 ;
         int stringLength = 0;
         String sessionId = null;
         String checkSessionId = null;
         String tempCounter = "";
         boolean flag = false;
         HttpSession hs = request.getSession(true);
         checkSessionId = (String)hs.getValue("sessionId");
         if(checkSessionId == null){
              sessionId = request.getSession().getId();
              hs.putValue("sessionId", sessionId);
              flag = true;
         checkSessionId = (String)hs.getValue("sessionId");
         if(flag) {
              counter = hitCounter.getNextCount();     
         else{
              counter = hitCounter.getCount();
         tempCounter = Long.toString(counter);
         stringLength = tempCounter.length();
         for(int count = 0 ; count < stringLength ; count++){
    %>
              <b><%=tempCounter.substring(count, count + 1)%></b>
    <%
    %>This JSP page can be included in your main JSP page
    Here is the Java class
    public class HitCounter{
         private long hitCounter;
        public HitCounter(){
              Runtime.getRuntime().addShutdownHook(new SaveCounter(this));
              try{
                   DataInputStream dis = new DataInputStream(new FileInputStream(NamedConstants.ERROR_FILE_PATH + "myCounter.txt"));
                   hitCounter = dis.readLong();
                   dis.close();
              }catch(EOFException ee){
                   saveIT();
              }catch(Exception e ){
                   System.out.println("Exception thrown " +e);
         public long getNextCount(){
               ++this.hitCounter;
               saveIT();
               return this.hitCounter;
         public long getCount (){
              return this.hitCounter;
         public void saveIT(){
              try{
                   DataOutputStream dos = new DataOutputStream(new FileOutputStream(NamedConstants.ERROR_FILE_PATH + "myCounter.txt"));
                   dos.writeLong(hitCounter);
                   dos.close();
              }catch(Exception e ) {
                   System.out.println("Exception thrown while saving "+e);
         protected void finalize(){
              saveIT();
    }

  • (Hit Counter)Very Urgent Plzzzzzzzzzzzzzzzzzzzz

    Guys can any 1 help me in developing a web page hit counter using JSP based on specific territory .....hope u guys got it ????? For ex: i want to count number of hits only from US
    Message was edited by:
    M......Factor

    Lol, BalusC was written while Java 1.5 wasn't out yet.still no need for the newb-crushing ternary logic :-)
    public class BalusC {
        public boolean readTopic(Topic topic) {
            return !topic.getSubject().toLowerCase().indexOf("urgent") == -1;
    }

  • How do I add a hit counter to my website?

    How do I go about adding a hit counter to my web site?
    I am running Adobe Dreamweaver CS6.

    Humm.......hit counters are meaningless. They don't provide accurate figures of who has visited your website.
    You'd be better off putting Goolge Analytics on the site - that will give you more accurate feedback.
    If you want to just have some fun Google Web Counter - there are plenty of free resources where you can download the code needed and insert it into your websites page.
    Just grab the code and paste it where you want the counter to show up on your page (not recommended)
    http://www.simplehitcounter.com/

  • How do I add a hit counter to my Gallery?

    So much I can't find instructions for on this board, in FAQ or in iWeb or iPhoto help.
    Anyone know how to add a hit counter to the gallery used when iPhoto publishes pictures?

    I still have not been able to add a hit counter to my gallery. I have no problem adding them to iWeb pages so it is frustrating that it's not as easy.

  • I need Java code for a simple graphical hit counter for a webpage

    I was wondering if anybody out there could send me some code for a simple graphical hit counter for a webpage. All the sites that I've visited are garbage and of no use to me. Please help me.
    Colin

    Not as easy as you'd imagine with applets. You need some way to store the hits, usually through a file on the server. That's not gonna happen in a hurry for 2 reasons -
    - Applets can't read/write files
    - Your web server usually won't let you run programs on their machine (ie, programs that listen for socket connections from applets, then load/read/write/close a file).
    In short, no, there is no simple java solution (that I know of).
    Cheers,
    Radish21

  • IWeb Hit Counter Widget

    My counting widget has disappeared from the widget list in iWeb. I deleted it from my page. How do I get it back?

    Try using the Insert->Button->Hit Counter menu option. If that fails then you might have to reinstall iWeb from the disk it came on. To do so you'll have to delete the current application and all files with "iWeb" in the file name that reside in the HD/Library/Receipts folder. Reinstall iWeb and apply the latest updaters.
    OT

  • Hit Count for a KM Folder

    Hi,
    Is there any way we can track the hit count for a particular folder in KM?
    Is there any particular default event where we can listen for this?
    Helps will be appreciated...
    Regards
    BP

    Hi BP
    This is the most recent information om KM statistics by Thilo Brandt:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7d28a67b-0c01-0010-8d9a-d7e6811377c0
    I don't know if it is possible, but I'd guess it's possible to alter that code in order to get some statistics on folder-level as well as item-level.
    Kind regards,
    Martin Søgaard

  • Hit Counter For Web Site Now Working?

    I have a web site that was published with iWeb 06. I am using a domain name at GoDaddy and forwarding to .Mac using masking so the site shows with the domain name not the .Mac address. If you went to the site by entering the domain name the hit counter on the first page would not show. However, if you entered the .Mac address to go to the site the counter would show.
    Well the site was republished and upgraded with iWeb 08. Recently I noticed that the hit counter now shows regardless of how you go to the site. I was pleasantly surprised but when did this happen? Of course as others have noticed, on my .Mac home page on the side bar where the website pages are listed the counter numbers no longer show. So they took something away and gave something back?
    John

    I don't think Apple meant to take away the .Mac counter section of the .Mac page. I think it's a bug that they have yet to resolve. It would be interesting to see if anyone has asked Apple about this and if they gave a definitive answer?

  • How do i get a hit counter on my site

    Hi everyone
    Im looking for a we hit counter for my site, but it seems
    like its abit more complecated than i want it to be, or am i
    getting it wrong?
    I have looked on the dreamweaver exchange, i dowloaded one
    called 'visit counter v.1.0' by felixone, and it says its on the
    server behaviours panel under the 'felixone' menu, but i cant find
    the server behaviours panel.
    Can anyone help? or does anyone have a good link to an easy
    to use one?
    Thanks

    You realise that 'hit counters' are pretty old hat and look a
    bit amateurish
    on a site these days :-)
    Check with your host, they may have a stats program that you
    can view to
    check out what hits and other information you can gather by
    the visitors to
    your site.
    If you really want a hit counter, you may be ble to find
    something at
    www.hotscripts.com
    Nadia
    Adobe® Community Expert : Dreamweaver
    CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    ~ Customisation Service Available ~
    http://www.csstemplates.com.au
    ~ Forum Posting Guidelines ~
    http://www.adobe.com/support/forums/guidelines.html
    CSS Tutorials for Dreamweaver:
    http://www.adobe.com/devnet/dreamweaver/css.html
    > Hi everyone
    >
    > Im looking for a we hit counter for my site, but it
    seems like its abit
    > more
    > complecated than i want it to be, or am i getting it
    wrong?
    >
    > I have looked on the dreamweaver exchange, i dowloaded
    one called 'visit
    > counter v.1.0' by felixone, and it says its on the
    server behaviours panel
    > under the 'felixone' menu, but i cant find the server
    behaviours panel.
    >
    > Can anyone help? or does anyone have a good link to an
    easy to use one?
    >
    > Thanks
    >

  • Hit Counter disappeared. How can I get it back?

    I've read numerous posts re Hit Counter, but none helpful to this:
    I publish only to MobileMe and have had no problem in the past. Problem is: today I removed lots of stuff I had added to my home page during the election campaigns. To remove them, I held down the Command key and dragged through lots of the stuff to select it, then hit Delete. I did not drag through the Hit Counter, nor the Apple logo, yet both of those disappeared too. Looking at the iWeb dropdown menu for adding these items, I saw that there was still a checkmark by the Hit Counter, but not by the Apple logo. So I clicked to check the logo, and it came back on the page no problem.
    But the Hit Counter, already still checked, was nowhere to be found. I increased my footer enormously, and searched in that space... not there. Nowhere.
    Next I unchecked and then rechecked the Hit Counter item in the menu. That didn't do it.
    I hate to uncheck it and then publish, and then check it again and republish. That might work, but I'd lose my count perhaps.
    How can I get back, or simply FIND, the Hit Counter on my page? The check mark says it's there, but I can't find it anywhere, have looked under lots of things on the page... nowhere!
    Thanks, anybody who's got a clue.

    Here's the solution:
    It occurred to me to vastly increase (temporarily) the vertical size of my page. (Remember, doing this with the footer hadn't helped.) When I increased the page size to a whopping 4000, there was the counter AND the original Apple Logo. I moved them into place, then put the vertical page size back to something reasonable. The count was retained.
    Thank you, self! (Sorry this didn't occur to me before posting, but since I have seen nothing of this advice in the discussion already, perhaps this will be helpful to someone else with the same problem.)
    I'll send Apple some feedback and hope they consider adding a line or two to the iWeb Help in it's discussion of the Hit Counter, given that so many of us have encountered problems.

  • Portal Users hits count on the homepage

    Hi all,
    I want to put hits count (total number of visitors) on my portal homepage, just like any other website. Don't have any idea how to do it. Can anyone guide me on this. Waiting for some quick response.
    Thanks in advance,
    Ganpati Jha

    hey ganpati .
    open your portal, login into  it.
    step1: go to tab into the top level navigation bar  System administrator --> support --> portal runtime --> browse deployment (in Test and Configuration Tools admin tools) --> download com.sap.portal.masthead.bak
    step 2:now rename that com.sap.portal.masthead.bak to com.sap.portal.masthead.par
    step3:
    now import that par file in netweaver developer studio and make the necessary changes like putting a variable to get incremented each time mast head is loaded. this way u can keep track of the number of hits.
    step4:  include .jar files of the downloaded par file to the
    for any clarification please ping again.
    reward if found useful.
    thx and regards.
    Anoop Gupta

  • Website hit count and rating stars

    Please assist I have 3 questions:
    1.       How to add the hit count on a website so that I can able to see how many people visited my site.
    2.       How to add the rating stars for music/video so that people can able to rate/vote for the best song/video of the month.
    Thank you for your help.

    I'm in complete agreement with JoeyD.  Hit counters add nothing special to a typical site.  Since they don't tell you where your hits are coming from or whether or not these are unique hits, I see no point in them.
    @ Shocker.  Your argument doesn't hold water. A regular web site is NOT the same as a web forum or blog where user participation is part of the whole experience. It's like comparing oranges to ducks - totally different.
    If you look closely at Adobe's main web site or any other commercial site like Apple or Dell you're not likely to see hit counters on them.  Why?  Because they're irrelevant.  The only people who care about site traffic are site owners and developers.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • Hit Counter button not appearing when I upload the web site.

    I am using iWeb version 3.0.4 on OS 10.6.8, and on the Welcome page, I added the Hit Counter button.  When I upload the web site, the Hit Counter button does not appear.  Anyone have any solutions as to why it isn't appearing?  Thanks...
    Peggy Hinsman
    Eugene School District 4j
    Eugene, Oregon

    Where are you hosting the site? The counter will not work on ftp servers, only on MobileMe.  If you are hosting on MobileMe increase the footer height considerable and publish. If the counter then appears you can move it closer to the body/footer border and reduce the footer height.
    If you're not on MobileMe consider a 3rd party counter like StatCounter.  This tutorial describes how to add it to iWeb pages: #13 - Adding a StatCounter as an HTML Snippet
    If you're on MobileMe you know that MMe will be discontinued on June 30 of next year.  This may be of interest: #23 - Life After MobileMe
    OT

  • Get hit count of a page or a dashboard (usage tracking)

    hi, experts, I found that I can get the query count (using count(*)) from usage tracking.
    but is it possible to get the hit count on a particular tab page or on a particular dashboard? not the query count on a page or a dashboard.
    thank you very much!

    Hi Nicolae,
    I did some digging and I found a few things out.
    Point 1) The OBIEE .dll files are what build up the HTML files based on their code and some "customizable" code in the XML files located in the messages folder of OBIEE (C:\OracleBI\web\msgdb\messages). I say "customizable" with quotes because although these files are editable, it is not supported by Oracle and any upgrade will overwrite your changes. That being said, we cannot change the code in the dll files, so our only other option is to play with the XML files and see if we can inject our script somewhere in their code.
    Point 2) The absolute last message from an XML file is the message that wrote the div with id="idSelsPermissionsDlgDiv". I had to do some grep'ing but I located the file which generated the final DIV. It is the commonuitemplates.xml file line 161. The bad thing is that the particular WebMessage is called multiple times ( I think three times based on my tests) in the building of the HTML. So if you put the code here, it would show up three different times in your HTML. Not ideal :(
    Point 3) The dashboardtemplates.xml document, line 410 is executed about four lines before the final body tag. This WebMessage is only executed once, so it is the closest you can get to the bottom of the page without having a duplicate entry. I recommend you paste the code from google right before the final html tag on line 410.
    Hope this helps!
    -Joe

Maybe you are looking for

  • Error while adding space to the table space

    HI Gurus Can you please put some light on the error which i encountered while adding space to a tablespace ALTER TABLESPACE "GISR_NDEX" ADD DATAFILE '+DATA2' SIZE 2G; ALTER TABLESPACE "GISR_INDEX" ADD DATAFILE '+DATA2' SIZE 2G ERROR at line 1: ORA-01

  • PROBLRM WITH MY CREATIVE MUVO NX HELP

    hi i have a little problem with my mp3. When it shold turn on , on display i see communicate "File system error" after that mp3's is turning off, what can I do. Please help me withe it. Thnx

  • IOS 6.0.2 battery draining BUG

    Need help plz. Just purchased a brand new phone from my local apple store in London. Once phone updated to 6.0.2 battery draining just started happening what should I do.

  • Does somebody has working example how retrieve ALL message ids from queue

    hello, i'm having problems retrievieng all message id's from queue using APPQ_MIB. Point is that i can't get cursor variable work. Somebody possibly has working example or knows how it is done in qmadmin? I'm using Tuxedo 8.0.

  • Contribute 3.11 to v4 ?   what's different?

    I've have looked for the last 1/2 hour all over Adobe, trying to find a page that would show me what is different/added from v3.11 to v4. does anyone have a clue, or a link, or anything?? thanks