Problem:
Release: Net Express 5.0
Consuming from a jsp and a Servlet, deployed on TOMCAT 5.0.28, a Java Bean generated by MF Interface Mapping Toolkit (IMTK) which, thru J2SE, invokes a Service deployed on Micro Focus Enterprise Server
Resolution:
============================================
The step of Micro Focus Knowledge Base article 23173 was about consuming a bean generated by Micro Focus Interface Mapping Toolkit by a sample JAVA client launched under a JVM ( ie: java client ), this Bean generated by MF Interface Mapping invoking thru J2SE a Service deployed on Micro Focus Enterprise Server.
KB 23173
Sample JAVA J2SE sample which invokes a service deployed on MF Enterprise Server
http://supportline.microfocus.com/mf_kb_display.asp?kbnumber=23173
============================================
The present STEP is about consuming the Bean above generated by IMTK in a jsp ( Java Server Page ) and in a Servlet.
To run this STEP, the bean which was created in previous STEP has to be deployed on MF Enterprise Server ( KB 23173 )
============================================
============================================
Environment:
Net Express 5.0 V 5.001.0099
TOMCAT 5.0-28
JDK 1.5.0_08
============================================
TOMCAT Environment Variable
CATALINA_HOME = C:\\Program Files\\Apache Software Foundation\\Tomcat 5.0
============================================
TOMCAT �TALINA_HOME%\\webapps\\ROOT ' region'
copied to
�TALINA_HOME%\\webapps\\MFdemo
You'll get a .ZIP of MFdemo you'll have to unzip on directory �TALINA_HOME%\\webapps
============================================
Now let's only work on the directory & sub-directories �TALINA_HOME%\\webapps\\webapps\\MFdemo
Copy of the file mfj2se.jar from NetExpress\\base\\bin to �TALINA_HOME%\\webapps\\MFdemo\\WEB-INF\\lib
( File used by the bean generated by IMTK )
Copy of the .jar HelloWorld.jar
to �TALINA_HOME%\\webapps\\MFdemo\\WEB-INF\\lib
HelloWorld.jar
was generated by MF IMTK in the previous STEP
============================================
============================================
--> Running the demonstration:
...The HelloWorld Service defined in KB 23173 has been deployed to a MF Enterprise Server region
...You have unzipped Mfdemo.zip to �TALINA_HOME%\\webapps
...You have started TOMCAT
THEN the following URLs would just run fine
( May be, depending on the JDK used, you'll have the compile the Servlet detailed beloww
============================================
============================================
>>>>
Accessing a sample HTML page:
http://localhost:8080/MFdemo/SimpleHTMLPage.htm
( just for a quick test )
>>>>
Accessing a sample JSP page
http://localhost:8080/MFdemo/SimpleJSPPage.jsp
( just for a quick test )
============================================
>>>>
jsp consuming the bean generated by MF IMTK which, thru J2SE, invokes a Service deployed on Micro Focus Enterprise Server
http://localhost:8080/MFdemo/SimpleJSPtoJBToServiceOnMF_ES.jsp
SimpleJSPtoJBToServiceOnMF_ES.jsp
<HTML>
<HEAD>
<TITLE>
JSP and Cobol Beans Demo </TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1253">
</HEAD>
<BODY BGCOLOR="cyan">
<%@ page import="com.mypackage.HelloWorld.HelloWorld" %>
<jsp:useBean id="myBean" scope="session" class="com.mypackage.HelloWorld.HelloWorld" />
<h3>
A jsp invoking a bean generated by MF IMTK which, thru J2SE, invokes a Service deployed on Micro Fosus Enterprise Server.
</h3>
<br><br>
<i>
<h4>
<% String StrPassedToEsService = new String("Mr Sherlock Holmes"); %>
<% out.println(myBean.sayHello(StrPassedToEsService)); %>
</h4>
<br><br>
<h5>
<% StrPassedToEsService = new String("Mr Mr Watson"); %>
<% out.println(myBean.sayHello(StrPassedToEsService)); %>
<h5>
</i>
</BODY>
</HTML>
============================================
>>>> Servlet sconsuming the bean generated by MF IMTK which, thru J2SE, invokes a Service deployed on Micro Fosus Enterprise Server
http://localhost:8080/MFdemo/servlet/HelloWorldExample
Servlet on webapps\\MFdemo\\WEB-INF\\classes
Servlet localed on
�TALINA_HOME%webapps\\MFdemo\\WEB-INF\\classes
Shell to compile the Servlet: �TALINA_HOME%webapps\\MFdemo\\WEB-INF\\classes\\compilServlet.bat
The file �TALINA_HOME%\\webapps\\MFdemo\\WEB-INF\\web.xml was modified to do the 'link' between an URL an a Java Class
Web.xml
…
Added
<servlet>
<servlet-name>HelloWorldExample</servlet-name>
<servlet-class>HelloWorldExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldExample</servlet-name>
<url-pattern>/servlet/HelloWorldExample</url-pattern>
</servlet-mapping>
Compilservlet.bat
SET CATALINA_HOME=C:\\Program Files\\Apache Software Foundation\\Tomcat 5.0
SET JAVA_HOME=C:\\Program Files\\Java\\jdk1.5.0_08
SET PATH=%WINDIR%;%WINDIR\\system32
SET CLASSPATH=.
SET PATH=%JAVA_HOME%\\bin;%PATH%
rem copy �TALINA_HOME%\\common\\lib\\servlet-api.jar .
set CLASSPATH=�TALINA_HOME%\\common\\lib\\servlet-api.jar;..\\lib\\mfj2se.jar;..\\lib\\HelloWorld.jar
javac HelloWorldExample.java
HelloWorldExample.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.mypackage.HelloWorld.*;
import com.microfocus.cobol.*;
public class HelloWorldExample extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Servlet Testing</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<h4>A servlet invoking a bean generated by MF IMTK which, thru J2SE, invokes a Service deployed on Micro Focus Enterprise Server</h4>");
out.println("<br><br>");
try
{
com.mypackage.HelloWorld.HelloWorld myBean = new com.mypackage.HelloWorld.HelloWorld();
String StrPassedToEsService = new String("Mr Sherlock Holmes");
out.println("<h3>" myBean.sayHello(StrPassedToEsService) "</h3>");
out.println("<br><br>");
StrPassedToEsService = new String("Mr Mr Watson");
out.println("<h2>" myBean. sayHello (StrPassedToEsService) "</h2>");
}
catch (CobolException e)
{
out.println(e.getMessage());
}
out.println("</BODY>");
out.println("</HTML>");
}
}
============================================
Demonstration:
ZIP of �TALINA_HOME%\\webapps\\MFdemo
To be unzipped on �TALINA_HOME%\\webapps