Log servlet 1.7


It is a Java servlet allows you to collect information about page visitors. You can put a reference to this servlet inside your pages and all relevant information will be collected in the given log file. And the reference to this servlet looks like a graphical dot on your page. This statistical component does not use JavaScript, so you can deploy it on mobile sites too.

How to use it:

a) copy logPackage.jar into your WEB-INF/lib directory.

b) define LogServlet in your web.xml file:
 


    <servlet>
     <servlet-name>LogServlet</servlet-name>
     <servlet-class>com.jsos.log.LogServlet</servlet-class>
    </servlet>

c) define a mapping:
 


    <servlet-mapping>
     <servlet-name>LogServlet</servlet-name>
     <url-pattern>/servlet/LogServlet</url-pattern>
    </servlet-mapping>

You may use this servlet in one of two forms. At the first hand you may set a path to your log file as a parameter to this servlet. So the usage (html code for your page) is:
 


   <img src="http://your_host/servlet/LogServlet?path_to_log_file" width=1 height=1 nosave>

or you can set a path to some directory. Log file (files) will be created within this directory automatically. File name will be selected according to the template: ddmmyyyy.txt where dd is current day, mm is current month and yyyy is current year:
 


   <img src="http://your_host/servlet/LogServlet?path_to_some_directory" width=1 height=1 nosave>

also you can define log file (directory) as an initial parameter for this servlet. Parameter name is log:
 


    <servlet>
     <servlet-name>LogServlet</servlet-name>
     <servlet-class>com.jsos.log.LogServlet</servlet-class>
     <init-param>
      <param-name>log</param-name>
      <param-value>path_to_log_file</param-value>
     </init-param>
    </servlet>

in this case you can use servlet so:
 


   <img src="http://your_host/servlet/LogServlet" width=1 height=1 nosave>

Log file is a text file with tab separated values. Each line contains:
IP address, date, URI in request, HTTP protocol, visitor's browser, referer page, visitor's charset, visitor's encoding, visitor's language (locale).

    For downloading:   logPackage.jar

 © Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: