Web hit counter

Can someone lead me in the right direction to making a hit counter in Java Studio Creator? The counter in staticText1 should increment every time some one hits the submit button. I didnt increment yet because I am getting errors when I try to parse it.
public String button1_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        String counter = (String)staticText1.getValue();       
        Cookie cookie = new Cookie(counter, "1");
        int counter = 1;
        cookie.setMaxAge(60*60*24*30);
        HttpServletResponse response =
                (HttpServletResponse)getExternalContext().getResponse();
        response.addCookie(cookie);
        staticText1.setValue(counter);
        return null;
public void prerender() {
        HttpServletRequest request = (HttpServletRequest)getExternalContext().getRequest();
I really dont know if I am doing is right.  I know I need to parse the counter in an int but I need a lead in the right direction.  Can anyone help?

I moved everything to the prerender method. And I made a few updates. However all i get is Blah. Anyone at all know how to fix this?
public void prerender() {
        staticText1.setValue("Blah");
        HttpServletRequest request = (HttpServletRequest)getExternalContext().getRequest();
        Cookie [] cookies = request.getCookies();
        if(cookies.length>1){
        for(int i=0;i<cookies.length-1;i++){
           Cookie cookie = cookies;
String counter = (String)staticText1.getValue();
Cookie cookie = new Cookie(counter,"1");
HttpServletResponse response =
(HttpServletResponse)getExternalContext().getResponse();
response.addCookie(cookie);
int count = 0;
count++;
try{
count = Integer.parseInt(counter);
}catch(NumberFormatException nfe){}
cookie.setMaxAge(60*60*24*30);
staticText1.setValue(counter);}

Similar Messages

  • Realtime web hits counter

    design question:
    1. A web site has 20000+ web pages/url's.
    2. at peak time, 8000+ concurrent users are visiting.
    3. 20+ pages are mostly hit concurrently.
    How can a counter track and report the hits accurately in real time(or semi real time) without sacrifice performance?
    1. synchronized can satisfy the accurate part, but will block threads and thus impact performance.
    2. can this problem be solved gracefully without using JMS?
    3. when multi threads put messages to one JMS Queue, only one thread at a time can put and other threads has to wait. is this correct?
    Thanks.

    [java.util.concurrent.AtomicLong.|http://java.sun.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicLong.html]

  • 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?

  • 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

  • Web page visit - hit counter

    Please advise of any tutorial or example of a web visit counter. 
    I can create one that increments the count for each visit and refresh but really need something that will count unique visitors.
    Maybe use a session but not sure how to do it.

    Depending on whether this is a casual hit counter, or something more mission-critical, there's a number of ways to accomplish this.
    One option is to increment the counter, then place a cookie on the user's computer. If the cookie is present, don't increment the counter again. Set the cookie to never expire, or expire after a certain window of time (after which the user would be considered "unique" again). Only drawback to this is if the user clears their cookies, then returns, the counter would consider them unique no matter what. Second, you could store each visit as a row in a database, along with the user's IP address and a date/time stamp. Your code could then query that table based on the IP address, and only increment the counter if that IP address is not present. Depending on how long you want to consider a user "unique", you could filter the rows by date. Keep in mind that this could result in a large table, depending on your traffic, so it may be best to have some sort of cut-off time after which you would delete records.
    You could even combine the two methods, if you so desire.
    I'm sure there are many other ways this can be accomplished, but these are two simple means to accomplish your goal.

  • Web stats for hit counter

    I've got a nice hit counter built with help from these
    forums. It's working beautifully. Now I'm building the web stats
    page. (no I'm just using CF7 and don't have CFStat from CF8 yet) I
    would like to display the total count for the month (which I've
    got) and then the daily breakdowns with the count for each day. I
    know there's got to be a dynamic way to set the queries up to do
    this without building 30 queries or more. I also want it to be able
    to continue through the years without me having to modify the
    dates.
    Right now my simple query looks like this.
    <cfquery datasource="#dsn#" name="sept">
    select referer, date from website_hits
    where page like '%home.cfm'
    and date >= '09/01/08'
    and date <= '09/30/08'
    </cfquery>
    and the output is correct with
    <cfoutput>#sept.recourdcount#</cfoutput>
    But I know this is not good coding. I must be overwhelmed or
    in a brain fog. Any thoughts?
    Thanks, Wendy

    Maybe I should be more specific. I got the monthly total
    query working using this
    <cfset today = #Dateformat(Now(), "mm/dd/yy")#>
    <cfset daytostart= #DateAdd("d",-thedatepart,today)#>
    <cfset daytostart = daytostart +1>
    <cfset daytostart = #DateFormat(daytostart,
    "MM/DD/YY")#>
    <cfquery datasource="#dsn#" name="monthly">
    select referer, date from website_hits
    where page like '%home.cfm'
    and date >= '#daytostart#'
    and date <= '#DateFormat(now(), "mm/dd/yy")#'
    </cfquery>
    <cfoutput>#monthly.recordcount#</cfoutput>
    <br>
    But now I need to pull out the daily totals. I'm toying with
    the query below. I'm assuming I need to loop this and be able to
    increment the date where it's currently hard coded. Is there a way
    to loop this and assign each date to a variable that I can use to
    display in a table?
    <cfquery datasource="#dsn#" name="thefirst">
    select date from website_hits
    where page like '%home.cfm'
    and date = '09/01/08'
    </cfquery>

  • Hit Counter For Web Site

    I've published a site to .Mac for a friend, and her domain name, which is hosted on godaddy is being forwarded to the .mac site. I'm using masking so only her domain name shows in the address bar of each page. That's all working well.
    I've added a hit counter through iweb to the first page but it won't show up when I go to the site by using the domain name. If I go to it using the .mac address it shows up. What's odd is if I go to the site first by using the .mac address where the counter always shows up then go to the site by putting in the domain name it will then show up there as well. If I go to the site again later by the domain name-no counter. If I repeat this by using the .mac address first then going back, it's there.
    I read other past posts about this issue but I didn't see if it could be completely resolved. I normally use Safari but even when I use Firefox it doesn't show up either.
    Can anyone help?
    John

    John:
    If you added the hit counter from within iWeb then that's the reason it doesn't show up. It will only work on the .Mac server.
    What you need to do is use StatCounter.com. It requires some post publication editing of the page that you want the counter on. If you make changes to the page later on then you'll have to reedit the page again.
    What has been suggested is to put a text box with "STATCOUNTER" in it where you want the counter to appear. Then in the post publication file, search for STATCOUNTER and replace it with the code that the site provides you.
    With that you can get daily, weekly hits, a world map of where the hits came from and lots more. There's a variety of text or image counters.
    In this site, Old Toad's Tutorials I put the STATCOUNTER in the main text box at the bottom and make the text orange. When I added the counter, it comes up in the text and color that I chose. If you put it in it's own text box, you can use the stye that StatCounter provides when you set up the counter.
    Do you Twango?

  • 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/

  • 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

  • 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

  • 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

  • Using microsoft.sharepoint.client.search.analytics to report the monthly hit count of site collections on SharePoint Online

    Is it possible to use microsoft.sharepoint.client.search.analytics to report the monthly hit count of site collections on SharePoint Online.
    GetHitCountForDay()
    GetHitCountForMonth()
    If yes, how can this be called and executed successfully from a Console application using the Client Object Model.
    Reference:
    http://download.microsoft.com/download/8/5/8/858F2155-D48D-4C68-9205-29460FD7698F/[MS-SPACSOM].pdf
    http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/54310f5f-e8a3-469e-86a3-63781b91670d/how-to-get-analytics-reports-programmatically-in-sharepoint-2013?forum=sharepointdevelopment

    Check if this works in 2013 as well.
    http://blogs.technet.com/b/sharepointdevelopersupport/archive/2012/10/04/how-to-retrieve-web-analytics-report-data-using-api.aspx
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Hit Counter on iWeb 08

    After I published my page with iWeb 08 the hit counter disappeared from my site. It is still there in iWeb just not in the published site.
    Is there a way to get it to work again? If I delete it and put it back in is there a way to start it at a given number so I don't have to start at zero again?

    You might want to see if it is just a problem with Safari caching. Sometimes Safari draws on the cache instead of updating the page correctly. You can fix this in several ways. This is probably the easiest:
    Open Safari
    In the 'Safari' menu choose 'empty cache'
    Go to your web site and see if the counter appears.
    Kurt

  • Hit Counter

    I was wondering if it is possible to supply a hit counter to my iweb page so I can see how many people have visited my site.
    Thank you to anyone who can help me.

    If you're publishing your site to MobileMe, see this Apple doc:
    _iWeb 3.0 Help: Counting visitors to your webpages_
    If publishing your site to another host, see this article:
    http://web.me.com/toad.hall/NewTutorials/main13.html
    More possibilities may be found by clicking HERE.

  • Hit counter on .Mac

    I've found that since upgrading to iWeb '08 the hit counter under My Pages on my .Mac home page is no longer there. It worked fine while I was working with iWeb '06. Everything else appears to be in order. The hit counter is working on the web page itself. Anyone with similar experiences?

    I am having a similar issue: hit counter worked for a while but today it no longer appears in published folders/internet. Could there be a corrupt file(i.e .plst)?

Maybe you are looking for