Creating JSP web applications using Visual COBOL for Eclipse
Getting Started with Visual COBOL for Eclipse
Creating web applications using JSPs and Tomcat
In this tutorial, we take you through the steps to create a web application using JSPs and Tomcat. To create web application in Eclipse we need install some new plugins, we’ll walk you through this step too.
First of all, you need to install the Web Tools Platform for Eclipse.
From the help menu, select Install New Software.
Paste this URL into the Work With entry field:
You also need to download Tomcat to host your JSP and COBOL JVM application.
Install Tomcat here. Choose the most current version of Tomcat and take a note the version you installed.
After installing Tomcat and WTP, switch back to Eclipse and create a new project.
From the File menu, select new -> other and then browse for the Dynamic Web Project
Click the next button, give the project a name
Click the “New Runtime” button
Select the version of Tomcat you installed, and click next
Enter location you installed tomcat to and click finish and click finish on the new dynamic web project project wizard.
Let’s now create the COBOL project.
From the file menu, select new COBOL JVM project
Name the project and click finish
Let’s add a new class to the COBOL project. Right-click the project and select new COBOL Jvm Class
Enter the name of the class and give it a namespace
Now let’s code up the method in the class just created.
class-id com.mf.CobolDemo public.
procedure division returning result as string.
set result to "Hello World"
Save the source file and check there are no compilation errors.
Let’s now configure the Java project.
First we need to add a reference to the COBOL project
Right click the java project and click properties.
Select deployment assembly in the left hand pane.
Click the add button and select Project, click next and then specify the COBOL project.
You also need to add a reference to the Micro Focus COBOL runtime, mfcobolrts.jar.
Click add and choose Archives from File System. Browse to your Visual COBOL installation directory and select mfcobolrts.jar from the bin folder.
Finally, click the Java Build path entry in the left hand pane, click the projects tab and choose add.
Specify the COBOL project click ok and click ok on the project properties page.
Now we have the projects configured correctly, we can create a JSP that calls the COBOL class to return some data.
Right click the Java project and select new other – from the list select JSP file.
If the JSP file isn’t open, right click the file in the project and choose open with, text editor.
Add the code highlighted below:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
com.mf.CobolDemo cd = new com.mf.CobolDemo();
You’re now ready to the application.
Make sure you JSP file is selected in the project view
Click the debug button on the toolbar
Click finish on the Debug On Server Page
Your JSP should look like this