Barcode Fonts, Components, ActiveX and .NET Windows Forms Controls, Java Servlets, 
DLLs and Barcode Scanners. IDAutomation.com, Inc., Computers Hardware, Software & Services, Tampa, FLThis site chose the Norton Secured Seal to promote trust online with consumers. View your cart in the IDAutomation Store


Home > Barcode Components > Java > Tomcat Streaming Barcode Generator Integration

Apache Tomcat Streaming Barcode Generator Integration Tutorial

IDAutomation's Java Servlets function as a streaming barcode generator which can be easily utilized within several applications. This tutorial will demonstrate how to implement streaming barcodes with the Apache Tomcat application server using IDAutomation's Java Servlets.

Order the JavaBeans, Applets & Download Demo of Barcode Generator for .NET Barcode Forms Control & DLL Support Forum

Configuring Apache Tomcat to Run Java Servlets

Java Servlets are used to add barcode support to a dedicated webserver. IDAutomation's Servlet is compatible with all browsers and is easy to embed in HTML as an image with the <IMG> tag. These Java Servlets can be hosted on a client's server and easily streamed to the desired application.

Linear Servlet Barcode Example:

  1. Install or verify use of Java (JDK or JRE) 1.2 or above. The encoder requires Java 1.2 or above to generate the image files used by the servlet. When possible, IDAutomation recommends installing the latest version of Java that is available.
  2. Special requirements for Linux and Unix servers:
    1. Be sure Java.awt GUI functions are available in the environment. This is not usually an issue with Windows® servers. In Unix or Linux, if the Java environment has the java.awt library stripped out, the Java products will not be able to generate images.
    2. If the server does not have an X-Window environment, either (1) use Headless Java or (2) connect to a remote X Server or (3) install the X Windows environment and run an X Windows session or (4) install an emulator, PJA library or virtual frame buffer as described in the XWindow Error Document.
  3. Download the demo or purchase the necessary IDAutomation Java Barcode Package and set the CLASSPATH environment variable to include all JAR files that need to be implemented. For example:
    CLASSPATH = C:\Program Files (x86)\Java\jre1.8.0_66\bin;C:\apache-tomcat-8.0.32\bin;C:\IDAutomationJava\LinearBarCode.jar
  4. Install Apache Tomcat according to the instructions and setup the required environment variables. In this example the following environment variables are set:
    CATALINA_HOME = C:\apache-tomcat-8.0.32
    JRE_HOME = C:\Program Files (x86)\Java\jre1.8.0_66
  5. Verify Apache Tomcat installation from a browser by opening http://localhost:8080/; if it does not open refer to the Apache Tomcat documentation for support.
    Verification that Tomcat is running
  6. Place the LinearBarCode.jar file in the /WEB-INF/lib directory of the appropriate WebApp. Since this example will use the root WebApp, the file is placed in "C:\apache-tomcat-8.0.32\webapps\ROOT\WEB-INF\lib". If the lib folder does not exist it will need to be created.
  7. Edit the web.xml in the appropriate /WEB-INF/ directory for the WebApp. Insert the following lines in the Servlet Mappings section before </web-app> to map a servlet-class to a URL:
      <servlet>
        <servlet-name>LinearServlet</servlet-name>
        <servlet-class>
    com.idautomation.linear.IDAutomationServlet</servlet-class>
     </servlet>
     <servlet-mapping>
        <servlet-name>LinearServlet</servlet-name>
        <url-pattern>/servlet/LinearServlet</url-pattern>
     </servlet-mapping>
    
  8. Restart the Apache Tomcat server by either restarting the service or executing the appropriate control scripts per system configuration. In this example shutdown.bat and startup.bat are executed from "C:\apache-tomcat-8.0.32\bin".
  9. After the servlet server is started, specify the appropriate URL that matches the url-pattern specified in web.xml above with any necessary parameters to stream the barcode image. The following generates a barcode encoding "123456789012":
    http://localhost:8080/servlet/LinearServlet?BARCODE=123456789012&EM=.06
    Servlet Barcode Generated from Apache Tomcat
  10. Once the servlet is working it may be integrated into any compatible application or included in HTML as a dynamic URL.

2D Data Matrix Servlet Example:

  1. Perform the steps above for the linear installation and verify that works properly.
  2. Place the appropriate jar file in the /WEB-INF/lib directory of the appropriate WebApp as described in step 6 above. This example uses the IDADataMatrix.jar file.
  3. Modify web.xml as described in step 7 above to include the additional servlet-name, servlet-class and url-pattern of the jar file:
      <servlet>
        <servlet-name>LinearServlet</servlet-name>
        <servlet-class>
    com.idautomation.linear.IDAutomationServlet</servlet-class>
     </servlet>
     <servlet-mapping>
        <servlet-name>LinearServlet</servlet-name>
        <url-pattern>/servlet/LinearServlet</url-pattern>
     </servlet-mapping>
    
     <servlet>
        <servlet-name>DataMatrixServlet</servlet-name>
        <servlet-class>
    com.idautomation.datamatrix.IDAutomationServlet</servlet-class>
     </servlet>
     <servlet-mapping>
        <servlet-name>DataMatrixServlet</servlet-name>
        <url-pattern>/servlet/DataMatrixServlet</url-pattern>
     </servlet-mapping>
    
  4. Restart the Apache Tomcat according to step 8 above.
  5. Open the appropriate URL that matches the url-pattern specified in web.xml with any necessary parameters to stream the barcode image.
    http://localhost:8080/servlet/DataMatrixServlet?BARCODE=123456789012&X=.1
    Data Matrix Generated from Apache Tomcat
  6. Other barcode types may also be implemented in the same way by specifying the appropriate servlet-class in web.xml.
 ©Copyright 2017 IDAutomation.com, All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us

Loading
Training Videos on YouTube  Join us on Google Plus  Join us on LinkedIn  Follow us on Twitter  Like us on Facebook
Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses.