326 eClient 101 Customization and Integration
14.1 Overview
There are many software application integration scenarios where users of an
existing application need an easy way to view content available through eClient.
For example, users of an insurance claims processing application may use a
custom-built application to locate basic claim information from a database
regarding insurance claims. After locating the claims, they may want to have an
easy way to view documents related to the claim (claim forms, photos, policy
documents, etc.) in eClient.
If using out-of-the box eClient to access the related documents, users have to
launch eClient, log on, select search templates, and enter search criteria (such
as claim numbers) to locate the documents. Users would have a better
experience if they could simply select a custom button or menu from their Line of
Business (LOB) application that would automatically show them a list of
documents in an eClient window for the claims they are looking for without having
to explicitly log on and enter the search criteria. The LOBIntegrator servlet and
some custom code in the LOB application can provide this type of functionality.
The key component required to implement this functionality is the LOBIntegrator
servlet. This servlet provides a new URL that is part of the eClient application
and can be invoked with specific parameters to specify logon and search
parameters. The servlet parses the parameters from the URL and automatically
logs on and performs a search. The search results are displayed in the standard
eClient window, allowing users to view and manipulate the documents.
The application you are integrating with may be written in one of many
languages. For example, it may be written in Java, Visual Basic, C++, FoxPro,
PowerBuilder, or perhaps it is a 3270 application running in an emulator. The
LOBIntegrator servlet can be used with any of these types of applications. Any
application that can launch a Web browser and pass a URL to it can use the
functionality of the servlet. Later in this chapter, we provide more information on
how to invoke the LOBIntegrator servlet from your LOB application.
14.2 Servlet source code
This section lists the source code for the LOBIntegrator servlet. The servlet can
be added to eClient to allow other applications to perform automatic searches by
generating a correctly formatted URL.
If you are integrating eClient with another J2EE application, you can add this
servlet to your custom J2EE application instead of adding it to eClient. Either
way, it does the same thing. Adding it to your custom J2EE application may be
better because you avoid any customization of eClient.
Chapter 14. Invoking eClient from another application 327
Example 14-1 includes the complete source code for LOBIntegrator servlet. You
can download a soft copy of the source code from Web. See Appendix B,
“Additional material” on page 465 for download instructions.
The source code is fairly simple. The bulk of the code is in the ProcessRequest()
method. It gets the parameters from the URL, performs the initialization and
logon if necessary, and builds a URL for the standard IDMSearch servlet in
eClient to perform the search and display the search results.
Example 14-1 LOBIntegrator servlet
/*
This 'as is' sample source code is provided with the IBM Redbook
SG246964. The source code is for a Servlet that can be added to
the eClient to allow an application to launch a browser with a
specific URL that will logon, perform a search, and display the
search results in the browser window.
*/
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import javax.servlet.http.HttpSession;
import com.ibm.mm.beans.CMBConnection;
public class LOBIntegrator extends HttpServlet {
public void init() throws ServletException {
super.init();
}
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
processRequest(req, resp);
}
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
processRequest(req, resp);
}
private String convertString(String strValue)
{
328 eClient 101 Customization and Integration
String strNewValue = "";
for (int i = 0; i < strValue.length(); i++)
{
if (strValue.charAt(i) == ' ')
{
strNewValue = strNewValue + "%2B";
}
else if (strValue.charAt(i) == '(')
{
strNewValue = strNewValue + "%28";
}
else if (strValue.charAt(i) == ')')
{
strNewValue = strNewValue + "%29";
}
else
{
strNewValue = strNewValue + strValue.charAt(i);
}
}
System.out.println("Old: " + strValue);
System.out.println("New: " + strNewValue);
return strNewValue;
}
public void processRequest(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
try {
String strTemp = "";
String url = "";
// Connection parameters and default values
String strServerName = "ICMNLSDB";
String strServerType = "ICM";
String strUserID = "icmadmin";
String strPassword = "password";
// Search parameters
String strSearchType = "";
String strSearchEntity = "";
String strSearchAttr1 = "";
String strSearchValue1 = "";
//
Get eClient 101 Customization and Integration now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.