hi Asha,
I think program is correct,you check your browser settings(related to
cookies).this might be one reason.
Thanks,
Hari
At 12:36 PM 11/29/99 -0800, you wrote:
>Hi :
> This is My simple seesion tracking program , count no of times the pages
>is hited. It is giving alwys me count 1 even i refresh the page 10 times.
>Please Help me!
>
>Thanks
>Asha
>
>
>import java.io.*;
>import java.util.*;
>import javax.servlet.*;
>import javax.servlet.http.*;
>
>
>public class SessionTracker extends HttpServlet {
>
> public void doGet(HttpServletRequest req,HttpServletResponse res) throws
>ServletException ,IOException
> {
> res.setContentType("text/html");
> PrintWriter out = res.getWriter();
>
> // Get the current session object, create one if necessary
> HttpSession session = req.getSession(true);
>
> out.println("<HTML><HEAD><TITLE>SessionTracker</TITLE></HEAD>");
> out.println("<BODY><H1>Session Tracking Demo</H1>");
>
>
> // Increment the hit count for this page. The value is saved
> // in this client's session under the name "tracker.count".
> Integer count = (Integer)session.getValue("SessionTracker.count");
> out.println("after gettig ="+count+"<br>");
>
>
> if (count == null)
> {
> out.println("inside null gettig ="+count+"<br>");
> count = new Integer(1);
> }
> else
> count = new Integer(count.intValue() + 1);
> session.putValue("SessionTracker.count", count);
>
>
>
> // Display the hit count for this page
> out.println("You've visited this page " + count +
> ((count.intValue() == 1) ? " time." : " times."));
>
> out.println("<P>");
>
> out.println("<H2>Here is your session data:</H2>");
> String[] names = session.getValueNames();
> for (int i = 0; i < names.length; i++) {
> out.println(names[i] + ": " + session.getValue(names[i]) + "<BR>");
> }
> out.println("</BODY></HTML>");
> file://out.close <file://out.close> ();
> }
>}
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html