Re: use http1.1 to find how long a user spend on a site

Michael Weller <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
I got another suggestion how to find out how long a user was on a
specific page. I'd use some simple JavaScript:

<head>
    <script language="javascript">
       var start;
       function initDate() {
          start = new Date();
       }
       function handleLink(target) {
          document.location = "http://foo.com/myServlet?time="+(new
Date()-start)+"&target="+target;
       }
    </script>
</head>
<body onload="initDate()">
    <a href="handleLink('homepage')">To Homepage</a><br>
    <a href="handleLink('shop')">To the Shop</a>
</body>

Of course, the big disadvantage of this approach is that users aren't
able to navigate if their client doesn't support JavaScript, or if they
don't want it to :-(

-mw

Gang Zhang schrieb:

>Hi,
>   This is just a suggestion.  I thought about it before and am pretty sure
>a lot of people also thought about it.  There is no way to know excatly how
>long a user has spend on a site (because we don't know how long he/she spend
>on the last page).
>
>  However if the useragent is http1.1, then it usually connect to the server
>with just one connection, and when the user close the browser window after
>he/she view the last page, the connection closes.  Apache (which uses
>trunked transfer mode) will know the socket is closed, and if we can add a
>message type to the AJP protocal, then the servlet side can know the
>connection is closed, and hence know the user has closed the browser.
>
>  Of course there could be the situation where the close connection ack is
>lost in trafic and the end time is longer then the actual time, but that
>should be more accurate then the lost time for the last page in most cases.
>
>      Gang
>
>___________________________________________________________________________
>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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.