Implementing Barcodes with Apache Tomcat using Java
Servlets
This tutorial will demonstrate how to implement barcodes with the
Apache Tomcat application server using IDAutomation's Java Servlets.
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 easily hosted on a client's server
or outsourced by an
ISP that supports Java Servlets.
Servlet Barcode Example Using
Apache Tomcat:
- Place the LinearBarCode.jar file in the /WEB-INF/lib directory
of the WebApp.
- Install or verify use of JDK 1.2 or above. The encoder requires
Java 2 or JDK 1.2 or above to create the JPEG files used by the
servlet.
- Special requirements for Linux and Unix servers:
- Be sure Java.awt GUI functions are available in the environment.
This is not an issue with Windows® servers. In UNIX or Linux,
if the Java environment has the java.awt library stripped out,
then the Java products will not be useable.
- 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. If the server has problems in this
area and the ability to modify the environment is not an option,
try outsourcing to an
ISP that supports
Java Servlets if possible.
- Edit the web.xml in the appropriate /WEB-INF/ directory for
the WebApp. Insert the following lines in the Servlet Mappings section:
<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>
- Restart the Apache Tomcat server by either restarting the service
or executing the appropriate control scripts per system configuration.
- After the servlet server is started, type the following code
into a browser and specify applet parameters to create the barcode.
This URL creates a barcode encoding "12345678" with a height if
.8CM:
http://localhost:8080/servlet/LinearServlet?BARCODE=12345678&BAR_HEIGHT=.8
- Once the servlet is working, see
Inserting Barcodes
into HTML.
|