net.sourceforge.barbecue
Class BarcodeServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bynet.sourceforge.barbecue.BarcodeServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class BarcodeServlet
extends javax.servlet.http.HttpServlet

The query parameters for this servlet are:

  1. data, required, example: "1234567890"
  2. type, optional, examples: "Code128A", "Code128B", "Code128C", if left blank will default to Code 128 B. Note that the type here must be exactly the name of one of the createX methods on BarcodeFactory without the "create" prefix. This is case sensitive.
  3. appid, required for UCC128 type, ignored for all other types - specifies the application identifier to use with the UCC128 barcode, example: "420" for a US postal service barcode
  4. width, optional, in pixels
  5. height, optional, in pixels
  6. resolution, optional, in dpi
  7. headless, optional, set to "false" to force non-headless mode for the servlet - default is "true"
  8. drawText, optional and only takes effect if headless is "false", set to "false" for no text

Example URL: http://hostname:80/myapp/BarcodeServlet?data=12345&type=Code128A

Contributed by Robert Chou <rchou at users.sourceforge.net>

Author:
Robert Chou, Ian Bourke, Sean Sullivan
See Also:
Serialized Form

Constructor Summary
BarcodeServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          From HttpServlet.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          From HttpServlet.
protected  Barcode getBarcode(java.lang.String type, java.lang.String data, java.lang.String appId, boolean checkSum)
          Returns the appropriate barcode for the speficied parameters.
 java.lang.String getServletName()
          From HttpServlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BarcodeServlet

public BarcodeServlet()
Method Detail

getServletName

public java.lang.String getServletName()
From HttpServlet.

Returns:
The literal string 'barbecue'

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException
From HttpServlet.

Parameters:
req - The servlet request
res - The servlet response
Throws:
javax.servlet.ServletException - If an error occurs during processing

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException
From HttpServlet.

Parameters:
req - The servlet request
res - The servlet response
Throws:
javax.servlet.ServletException - If an error occurs during processing

getBarcode

protected Barcode getBarcode(java.lang.String type,
                             java.lang.String data,
                             java.lang.String appId,
                             boolean checkSum)
                      throws javax.servlet.ServletException
Returns the appropriate barcode for the speficied parameters.

Parameters:
type - The barcode type
data - The data to encode
appId - The (optional) application ID - for UCC128 codes
checkSum - Flag indicating whether a checksum should be appended to the barcode - for Code 39 barcodes
Returns:
The barcode
Throws:
javax.servlet.ServletException - If required data is missing


Copyright © 2003-2007 barbecue.sourceforge.net. All Rights Reserved.