Follow

Running a Web Application on Raspberry Pi

Installing a Web Application Server

To run Elastic COBOL programs as web applications, we first need to install a Web Application Server. For this example we are going to use Apache Tomcat 7 which can be downloaded and installed for free.

$ cd $HOME
$ wget http://mirrors.axint.net/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
$ tar xzf apache-tomcat-7.0.42.tar.gz
$ mv apache-tomcat-7.0.42.tar.gz tomcat7

Before we start Tomcat, we need to add a user that has permissions to deploy applications:

$ cd $HOME/tomcat7/conf
$ vi tomcat-users.xml

Immediately after <tomcat-users> add the following line and save the file:

<user username="system" password="raspberry" roles="manager-gui"/>

Now let's start Tomcat:

$ cd $HOME/tomcat7/bin
$ sh startup.sh

Using CATALINA_BASE: /home/pi/tomcat7
Using CATALINA_HOME: /home/pi/tomcat7
Using CATALINA_TMPDIR: /home/pi/tomcat7/temp
Using JRE_HOME: /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt
Using CLASSPATH: /home/pi/tomcat7/bin/bootstrap.jar:/home/pi/tomcat7/bin/tomcat-juli.jar

You should now be able to access Tomcat's management console by entering the following into your browser:

http://[your-raspberry-pi-IP-address]:8080/manager/html

User Name: System
Password: raspberry

 

Compiling & Packaging the Application for Tomcat

$ cd $HOME/ec4rpi/samples/servlet-register/resources
$ ecc register
Elastic COBOL V14.11.8 Copyright (C) 2010-2014 Heirloom Computing

LOC: 440 (42 variables in 3 records)
Warnings: 0
Errors: 0
Result: Compilation SUCCESSFUL
Building: Class files

You can find out details and specifics on what needs to be done to successfully deploy a web application to Tomcat here. The following instructions are abridged specifically for this application:

$ mkdir WEB-INF WEB-INF/classes

This is part of the required deployment structure.
$ cp reg*class WEB-INF/classes

This is the application code produced by Elastic COBOL.
$ unzip -q $HOME/ec4rpi/ecobol.jar -d WEB-INF/classes

This is the Elastic COBOL runtime.
$ cp $HOME/elasticcobol.properties WEB-INF/classes

This is the Elastic COBOL license file.

Use the web.xml file (the application's deployment descriptor) that is attached to this article to create a copy on your Raspberry Pi.

$ cp /tmp/web.xml WEB-INF
$ jar cf register.war register.html register.cbl WEB-INF

This creates a WAR (Web application ARchive) application package that can be deployed to Tomcat.

 

Deploying & Executing the Application Package

$ cp register.war $HOME/tomcat7/webapps

This will "hot deploy" the application to Tomcat.

Installation of the application will take a minute or so. You will know that the application has been successfully deployed when the Tomcat management console lists the application as "Running" (true).

rpitomcat1.PNG

You should now be able to access the deployed application by entering the following in your browser:

http://[your-raspberry-pi-IP-address]:8080/register/register.html

This will display the web form that is going to invoke the Elastic COBOL register servlet.

You can fill out the form (required fields are in bold), or you can simply scroll down to the bottom of the form and click "Register Software". This will cause the COBOL servlet to process the empty form and report back:

rpitomcat2.PNG

You can click on "register.cbl" at the top of the page to view the application source in the browser.

 

Other

If you want to shutdown your Tomcat server, do the following:

$ cd $HOME/tomcat7/bin
$ sh shutdown.sh

 

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk