I don't have a whole lot of time to go into detail. But, my initial thoughts
about this is to have some sort of static variable in the servlet that is
incremented in the doPost/doGet methods and then, at various intervals, open
the file and add that number to the file.
I know that's a very high level view of  a possible solution but it may be
something to think about.

--- Wai Mun <[EMAIL PROTECTED]> wrote:
> hello:
>
> i'm thinking of writing every count for every servlet visit to a counter
> file. this file would record the datetime, name of servlet visited, and this
> file will be read easily (txt format) by means from browser or whatsoever.
>
> question is: how do i update the counter file efficiently? and also
> considering concurrent access. i thought of one: that is to open & close the
> file everytime the servlet is called. is this a good method, a preferred
> one? or anyone can suggest a better solution to this?
>
> say my servlet is as follows:
> /* servlet one */
> public void doGet(HttpServletRequest request, HttpServletResponse response)
> throws ServletException, IOException {
> response.setContentType("text/html");
> PrintWriter out = response.getWriter();
>
> /* updating of counter file here
> ...........
> ..........
> ..........
> */
>
> out.print("servlet one");
> out.close();
> }
>
> /* servlet two */
> public void doGet(HttpServletRequest request, HttpServletResponse response)
> throws ServletException, IOException {
> response.setContentType("text/html");
> PrintWriter out = response.getWriter();
>
> /* updating of counter file here
> ...........
> ..........
> ..........
> */
>
> out.print("servlet two");
> out.close();
> }
>
> /* servlet three as per previous */
> /* servlet four as per previous */
>
> ___________________________________________________________________________
> 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


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/

___________________________________________________________________________
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

Reply via email to