- Dynamic JPEG Image
- Dynamic PNG Image
- Barcode Size and Printer Resolution
- Threading Model
<img src="..../BarcodeServlet?image=3&type=6&data=12345678"> or <img src="barcode.jsp?image=3&type=6&data=12345678">in your HTML file and, voila, you have a dynamically generated Code 39 barcode image.
The advantage of the JPEG image format is that it's supported by virtually all commercial grade browsers in all their versions.
It's well-known that JPEG uses lossy image compression. BarCode/JSP generates JPEG with high quality (thus low compression). The result is fairly good. However, you may see background noises when printing using Netscape; we think that's because Netscape adopts a low quality decompression approach (yes, like compression, you can specify a quality parameter for decompression, too). Fortunately, our tests show that the result is still scannable in our test conditions (300 dpi laser printer).
<img src="..../BarcodeServlet?image=1&type=6&data=12345678"> or <img src="barcode.jsp?image=1&type=6&data=12345678">Unlike JPEG, PNG uses lossless image compression and gives you high quality images. The only drawback is that PNG is only supported by recent browsers (i.e., IE 4.0 or later and Netscape 4.04 or later). If you're target these browsers, we highly recommend you use the PNG image format.
Why Not GIF?
GIF is not supported for legal reasons. We'll support GIF when there's enough demand for it. In fact, any web site operators who use GIF generation software on their web site would need to pay a substantial amount in royalty fees to Unisys Coporation (several thousand dollars as of this writing), in addition to any up-front fees that the software developer would have to pay it.
If you find the barcode size too big, you can specify a Threading Model
If you have to script BarCode/JSP directly, you need to know that a Barcode instance
is not thread safe.
This means each Barcode instance can only be accessed safely from within a single
thread (you can have multiple instances belonging to different threads, though).
This is perfectly fine within an HTTP servlet's service, doGet or doPost method and
within a JSP page, as long as you create a new instance each time and are done with it
upon leaving the method or JSP page.