My WML Counter Home Page

WBMP File Creation From Java Byte Arrays

Purchase Info

While searching for a website hit counter to use in our WML WAP mobile browser website, it was hard to find more than a few available. We were not able to find any that allowed the count to be displayed as part of the browser page. Instead, the count was provided as part of a new page.

We decided to write our own counter that would provide the number of hits as an WBMP image. This image would be sent to the browser as part of the WML 'image' tag.

Our first objective to get this accomplished was to find out how a WBMP image file constructed. Fortunately, I found an excellent source for this information entitled Dynamic generation of WBMP graphs from XML data using JavaBeans and JSP, courtesy of the IBM developerWorks Wireless website.

Given that the WBMP image format is a binary file, a Hex Editor would prove helpful to accomplish my goal. We chose to use a free Hex Editor from Christian Mass' website. This proved a worthwhile tool for the rudimentory creation and editing of WBMP files. As we created a file for each digit, we rendered the image in the Wireless Companion wireless browser emulator after serving them from the local web server that is part of the Sun One Java developement IDE. Again, both tools are free. The Wireless Companion is avaialable from yourwap.com and the Java IDE is available from Sun Microsystems, Inc.

Once we were satisfied with the appearance of each digit, we created a Java servlet that would assemble a single image to display muliple digits as needed to provide a display of the number of website visitors. We created a byte array to include the necessary bytes to display the image of each digit. When the servlet is called from the image tag of a home page, the previous count value is accessed from a local file, and incremented to reflect this website visit. The servlet then performs a loop, which access a single row of pixels in each of the digits of the counter number in succession, then repeats the process for the next row of each digit byte array continuing until the image file is created to reflect the necessary digits portraying the counter value.

The newly create image byte file, is sent to the browser using http protocol and the local count file is saved with the new incremented value. The implementation of this process can be seen from the mobile website home page of The Socker Fan found at www.sockerfan.com/tsf.wml

If you have a mobile web browser, drop by and see the results.



Purchase Instructions

We offer mobile counters to WML webmasters at the modest cost of $15 USD per year. Email us at field_general@fieldmaster.org and include WBMP Mobile Counter in the subject line of your email. You will receive full instructions and your counter URL in 24 hours.



Click here to return to The Fieldmaster home page...
www.fieldmaster.org