The Artima Developer Community
Sponsored Link

Java Answers Forum
Conter for Page Hits

1 reply on 1 page. Most recent reply: Jan 19, 2004 5:22 AM by mausam

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Birendar S Waldiya

Posts: 21
Nickname: ebiren
Registered: Nov, 2003

Conter for Page Hits Posted: Jan 16, 2004 3:03 AM
Reply to this message Reply
Advertisement
Hi Forum,

I have a quetion to get suggestion regarding the page hits on a page.can any one give me the idea how can i count the number of times a particular page is being accessed by any users the system.
thanks


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Conter for Page Hits Posted: Jan 19, 2004 5:22 AM
Reply to this message Reply
for a session, can use this programme
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
public class SimpleCounter extends HttpServlet {
 
  int count = 0;
 
  public void doGet(HttpServletRequest req, HttpServletResponse res) 
                               throws ServletException, IOException {
    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();
    count++;
    out.println("Since loading, this servlet has been accessed " +
                count + " times.");
  }
}
 


for lifetime...set this counter in the database and retrive it from database on each request

Flat View: This topic has 1 reply on 1 page
Topic: library Previous Topic   Next Topic Topic: Convert in java string to UCS-2 format for saving in DB

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use