YOUR FEEDBACK
More on the Software Assembly Question - Do Design Patterns Help?
Yanic wrote: Hi, > UML and MDA are being changed to be more data and doc...
SOA World Conference
Virtualization Conference
$50 Savings Expire May 23, 2008... – Register Today!


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
POWERBUILDER LINKS YOU MUST CLICK ON


Building A JSP-JaguarCTS-PowerBuilder Bridge

Digg This!

This article demonstrates how to use JavaServer Pages (JSP) to manipulate PowerBuilder DataWindows. We'll create a Jaguar- CTS component in PowerBuilder and call it from JSP. Using techniques from our Hepek Dual Architecture Framework, we'll show how to Web-enable your existing DataWindows in a matter of minutes.

We'll also visit a few technologies appropriate to this article and introduce each to the extent needed. We'll briefly go over Tomcat and the JSP container/engine, along with the associated setup. Once we've completed a fairly simple example, we'll introduce our Hepek DAF extension for JSP. The following tools will be used:

  • EAServer 3.6.1 (build 36105)
  • PowerBuilder 7.0.2 (build 8003)
  • Jakarta Tomcat 3.2.1 (downloadable from http://jakarta.apache.org/tomcat/)
  • Windows NT4.0 with SP6a
  • Hepek DAF (as a guideline)
This article isn't a fully detailed tutorial on JSP or any of the other technologies mentioned. Instead, we'll concentrate on how to build a JSP-JaguarCTS-PowerBuilder bridge.

What Is JSP?
JSP is an extension of Sun's servlet technology. You can think of a JSP page as Java code embedded in a Web page. Servlet/JSP technology allows separation of the user interface from actual content generation or business logic. In our case the PowerBuilder component residing on JaguarCTS will contain business logic and will perform content generation.

JSPs are files with a .jsp extension, executed in what is known as a servlet container or, in JSP context, a JSP container. Some of the older literature you may come across refers to a container as an engine. Basically, a JSP container is kind of a filter for JSP code, which is, in fact, Java code. The container receives a .jsp page that contains Java/JSP, JavaScript, or HTML code. The container filters out and executes Java/JSP code only. Each JSP page is compiled into the servlet by the container. Output of the container is pure HTML or other data that represents content.

In our example we'll use Jakarta Tomcat as a container. A JSP container is a process that's initiated when the HTTP server starts. Only one container/process is used over the life span of the HTTP server that takes care of all servlet/JSP requests. This one instance of the container handles multiple requests by using Java threads, making a JSP/servlet execute faster than a Common Gateway Interface (CGI), for example, as there's no need for the operating system to create a new process for each request. Creating a new process is one of the more expensive tasks performed by the OS.

JaguarCTS 3.6+ has its own built-in JSP container. We've avoided using it, however, as we determined that it's better to separate the servlet container and the application server. Future releases of JaguarCTS will provide a container as a plug-in to Web servers, thus reinforcing our opinion.

Object-Oriented Programming
The separation of business logic and presentation by the use of JSP provides flexibility and rapid application development. Your company can have a design/interface team that will create the HTML or JSP pages and graphics for the Web page. Simultaneously, using PowerBuilder or PowerJ, your development team can create PB components and EJBs without affecting the work of the other group. The design team needs only to know what the component interface is, allowing the two teams to work harmoniously.

JSP is often compared to Microsoft's Active Server Pages. Both JSP and ASP were created to support the development of dynamic content for browser-based applications. There are, however, many differences between the two. JSP technology embraces the write once, run anywhere philosophy of the Java architecture. When it comes to what the components can do on the client's machine, JSP/Java uses a sandbox approach and ASP/ActiveX uses a certificate approach.

JSP is generally better for large projects, while ASP is convenient for smaller ones. The reason lies in the object-oriented nature of Java. Within enterprise-wide-sized projects, ASP has a tendency to result in spaghetti code, creating maintenance nightmares. If you've visited large commercial Web sites lately, you may have observed that many of them are transitioning from technologies like CGI, ASP, and ColdFusion to JSP.

Some examples are Chase Manhattan Bank and the CitiBank Group. As far as the change from PowerBuilder to Java and JSP is concerned, we PB developers should have an easy transition. Concepts used in these technologies are strongly object-oriented and very similar to those of PowerBuilder. It should be noted that JaguarCTS provides support for both JSP and ASP. We strongly recommend JSP over ASP.

Setting Up Tomcat
We won't use EAServer as the Web server in these examples nor will we use EAServer's servlet/JSP container. In general, we consider it a good practice to separate these tiers. We typically use Apache as the Web server, Tomcat as the JSP container, and JaguarCTS as the application server. This separation has proved to be good for scalability and security.

In the examples presented Tomcat will serve as the Web server as well as the servlet/JSP container. We'll show you how to set it up to work with JaguarCTS. In case you get stuck in the Tomcat setup and need more details, please read the documentation that comes with it. If you still experience turbulence, visit the Dean Jones Web site at www.powerobjects.com and follow his instructions on connecting Tomcat and JaguarCTS.

If you haven't downloaded Tomcat yet, visit http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.1/bin/ and download file jakarta-tomcat-3.2.1.zip. Extract the zip file (the default extract destination is C:\jakarta-tomcat-3.2.1). Once you extract the files, we recommend changing the default directory to C:\Tomcat for convenience.

You'll need to set up two environment variables: TOMCAT_HOME and JAVA_HOME. Right-click on the My Computer icon on your desktop and select Properties from the displayed menu. Click on the Environment Tab and you'll see something similar to Figure 1. Enter values for TOMCAT_HOME and JAVA_HOME and create these two variables as shown in the figure. Now you can test Tomcat.


Figure 1: WinNT System Properties

To start, go to %TOMCAT_HOME%\bin and double-click on startup.bat. If everything is okay, Tomcat will start and a DOS window will open. To shut Tomcat down, double-click on shutdown.bat.

As mentioned earlier, we'll use Tomcat as the HTTP server as well as the servlet/JSP container. By default, Tomcat listens for HTTP requests on port 8080, the same port on which EAServer listens for HTTP requests. To avoid conflict between the two, modify either or both of them. As is often the case with computers and software, there's a trick to having the two work together without modifications. If you start Tomcat first and then JaguarCTS, you don't need to modify either, as the first one to occupy the port takes precedence. The second one started won't be able to receive HTTP requests. (This is just for your information and should never be used as part of your practice.) Now that we have two possibilities, we'll show you how to handle both.

Modifying an EAServer HTTP Listener
We always modify the EAServer as we don't use it as the HTTP server. It's also less of a headache if you use a Web server like Apache. Open Jaguar Manager expands the Servers folder. Within that folder will be a list of your servers. Select the one you want to use to modify the listener. Expand it and click on the Listeners folder. On the right-hand screen you'll see a list of defined listeners. Right-click on the HTTP listener and select Listener Properties from the pop-up menu. Change the value for Port from 8080 to 8888, save your changes, and restart Jaguar. If you choose this approach to modify EAServer HTTP listener, you don't have to change anything on Tomcat and you can skip the following section.

Modifying a Tomcat HTTP Listener
If you decide to modify Tomcat, you'll find the server.xml file within the %TOMCAT_HOME%\conf directory. Open up server.xml for editing and locate the following section:

<!-- ========== Connectors =========-->
<!-- Normal HTTP -->
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
<Parameter name="handler"
value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
<Parameter name="port"
value="8080"/>
</Connector>
In this section you'll need to change the parameter "port" value from the default "8080" to some other value. We'll set this value to "8888". This will make Tomcat listen for HTTP requests on port 8888. By default, Apache and IIS both listen for HTTP requests on port 80, Jaguar and Tomcat on port 8080, and JRun on port 8000.

Continuing with Tomcat
To avoid minor code errors, set up Tomcat to use classes from JagClient.zip by modifying the %TOMCAT_HOME%\bin\tomcat.bat file. (To learn how, visit www.powerobjects.com.) Once you're finished with the Tomcat setup, start Tomcat by executing %TOMCAT_HOME%\bin\startup.bat. To test your Tomcat installation, open your browser and visit http://localhost:8888 or http://localhost:8080, depending on which approach you use. In your browser you should see a Tomcat default page.

Creating/Defining a Database
Connection Cache

For this exercise to cover the entire process and give you a thorough understanding, we need to create a Database Connection cache. We'll use the Examples ASA database that comes with EAStudio. Go to the Control Panel and open ODBC Data Sources. Select the System DSN tab and click the Add button. A new window will open. Select Adaptive Server Anywhere 6 from the list and click the Finish button. The ODBC Configuration for Adaptive Server Anywhere window will open.

Now set the following properties:

ODBC tab
Data Source Name: HepekPBDJ
Login Tab entries
User ID:  dba
Password:  sql
Database Tab
DataBaseFile: %SYBASE%\Shared\PowerBuilder\easdemodb.db
(Note: %SYBASE% is the path to the Sybase directory on your PC.)

Return to the ODBC tab and click the Test Connection button. You should get a Connection Successful message in the pop-up window.

Now we can use the HepekPBDJ data source to create a Connection Cache in JaguarCTS. Open up the Jaguar Manager and right-click on the Connection Cache Folder and select New Connection Cache. A new window opens, prompting for the cache name; call it HepekPBDJ. The Connection Cache Properties window will open. Set the properties as follows:

General Tab
Description: Hepek Pbdj Cache
Server Name: HepekPBDJ
User Name:dba
Password:sql
Driver Tab
DLL or Class Name:  odbc32.dll
ODBC radio button is selected
Cache Tab
Enable cache-by-name access is checked
Click OK. The Connection Cache Properties window will close.

Expand the Servers folder, then select and expand the Jaguar server. Right-click on Installed Connection Caches and select Install Connection Cache. A new window pops up, asking what you want to do. Click on Install an Existing Connection Cache button. The next screen comes up and prompts you to choose which connection cache to install.

HepekPBDJ should be listed, so high-light/select it and click the OK button. Now you should see HepekPBDJ listed on the right-hand side of the screen. Right-click on it and select Cache Properties. The Properties window will appear. Click first on the Refresh button and then on the Ping button. If everything has gone according to plan, JaguarCTS will respond with: "Ping of HepekPBDJ ODBC Connection Cache succeeded."

Creating a JaguarCTS Component
in PowerBuilder

Now we're ready to create the JaguarCTS components with PowerBuilder. Under your local C:\ drive, create the directory HepekPBDJ. Open PowerBuilder and from the File menu select New. You'll be presented with a window that provides you with the ability to create new objects. From the Start Wizard tab select the Jaguar Component icon and click the OK button. A guidingWizard opens with an information window. Click the Next button. Yet another information window opens, so click the Next button once again. The third window asks for the Application Name and Library. Enter values like those in Figure 2 and click the Next button.

On the following screen click the Next button once again. The Wizard moves to a new screen and asks for the Component Name, which should by default be n_hepekpbdj. If it isn't, enter it. You can add a description, but it isn't required. Click the Next button. When a similar screen appears, enter the Jaguar Component Name, which should already read n_hepekpbdj. If it doesn't, enter it and click Next. The next screen asks for information about your JaguarCTS server. Enter your server IP or Server Name, depending on how you defined the JaguarCTS IIOP listener. Enter the IIOP port and login information for your JaguarCTS server, and click Next.

We now enter the Package Name, which we'll identify as HepekPBDJ, and click Next. For the component type make sure that Standard Component is selected and click Next. For Component Instance Pooling we'll select Supported and click Next. For Transaction Support we'll select Not Supported. Make sure that Auto Demarcation/Activation is checked (see Figure 3).

The next window defines how JaguarCTS creates the component interface. Don't check anything, and click Next. And don't check anything on the Debug and Live Editing screens either. When you click Next, a new screen comes up and asks for the name of the project. Change the existing default value, p_hepekpbdj, to p_hepekpbdj_jag_deploy, and click Next. On the next screen make sure that both "build consolidated .pbd" and "include unreferenced objects" are checked and click Next. Then click Finish.

Now open up the library. The list of objects shown in Figure 4 should be contained within your hepekpbdj.pbl.

In our next article we'll create functionality for our n_hepekpbdj JaguarCTS component. We'll also develop a HepekPBDJ.jsp page that will communicate with the n_hepekpbdj component. This JSP page will be able to handle an HTML String or ResultSet sent by JaguarCTS. We'll then introduce advanced JSP-JaguarCTS techniques, such as linkage and query, using our Hepek DAF .t

About Tarik Makota
Tarik Makota is lead programmer analyst at Bowne Technology Enterprise.

About Nermin Tanovic
Nermin Tanovic, a senior technology specialist at Bowne Technology Enterprise, a major financial printing company in New York, is the author of the Hepek PowerBuilder Framework. His web site is www.hepek.com.

PBDJ LATEST STORIES . . .
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
The PB Future: More on Graphs in PowerBuilder 11.5
Last week I posted a screen shot of the new 3D Rendering capabilities being added to some of the 3D graphs in PowerBuilder 11.5. It was met with mixed reviews on the PowerBuilder Futures newsgroup (forums.sybase.com) so I went back to the drawing board to see what I could come up with.
BluePhoenix Expands Modernization Collaboration with Microsoft
BluePhoenix announced that it has expanded its collaboration with Microsoft on legacy modernization projects. The collaboration provides customers moving their applications or databases to .NET-based environments the best in both modernization services and technical support. BluePhoeni
Sybase PowerBuilder Delivers AJAX and .NET Enhancements Enabling Rich Internet Application Development
Sybase announced that AJAX development capabilities and further Microsoft .NET enhancements have been added to the latest version of Sybase PowerBuilder 11, the premier 4GL rapid application development (RAD) tool. PowerBuilder 11.2 represents another milestone in the PowerBuilder road
PowerBuilder 11.2 Released: Sybase's Flagship IDE
Sybase has released the production version of its flagship .NET development tool - PowerBuilder version 11.2. This latest release of its premier IDE for RAD includes not only standard fixes but also a good list of new features. Here is the 'Coles Notes' version of these new features.
PowerBuilder Takes You To .NET
In June of 2007, Sybase released PowerBuilder 11. PowerBuilder developers can now deploy PowerBuilder components as .NET Assemblies or as .NET Web Services. A PowerBuilder developer can now create these .NET resources so that those who develop .NET solutions can benefit from PowerBuild
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING POWERBUILDER / SYBASE NEWS
Sybase and Sun Set Guinness World Record for World's Largest Data Warehouse
Sybase, Inc. (NYSE:SY), the largest enterprise software and services company exclusively