Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Creating JSP web applications using Visual COBOL for Eclipse

Creating JSP web applications using Visual COBOL for Eclipse

Getting Started with Visual COBOL for Eclipse

Creating web applications using JSPs and Tomcat

Summary

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:

http://download.eclipse.org/webtools/repository/helios/



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

Click finish.



Now let’s code up the method in the class just created.

 

       class-id com.mf.CobolDemo public. 

       working-storage section. 

       method-id sayHelloWorld.

       local-storage section.

       procedure division returning result as string.

            set result to "Hello World"

           goback.

       end method.

         end class.

 

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"

    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

  <%

 com.mf.CobolDemo cd = new com.mf.CobolDemo();

 out.println(cd.sayHelloWorld());

 %>

 

</body>

</html>

 

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

 

 

 

 

 

 

 

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Version history
Revision #:
1 of 1
Last update:
‎2012-12-17 04:30
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.