BSP Programming: Handling Of Non-HTML Documents

BSP pages contain, effectively, HTML. When binary objects are requested, they are placed in the MIME repository and referenced from there. However, it is often necessary to handle binary objects/documents during the runtime of the program. It is not feasible to place these runtime documents in the MIME repository. (For any change in the MIME repository, transport records are written. This is usually not possible on a productive system, and is relatively slow compared to the runtime requirements of the running BSP application.)

Typical (real!) examples that we have seen:

§ For a personnel system, all colleagues’ pictures are available in a database table and must be displayed as part of an HTML page.

§ To use an ActiveX object (examples are Flash or SVG plug-in), it dynamically generates XML data that is available for the plug-in (via HTTP).

§ Some internal data is converted into a PDF document that must be displayed in the browser.

It would be interesting to look at three different ways to use/do this:

§ Assume we are somewhere on a BSP page and wish to display the complete document. Typical example: a button is pressed for a receipt, and then a PDF document must be displayed.

§ Next, a slightly more complex example is to display the new document as part of an HTML page. This requires that the HTML page must be rendered back and then, on a second HTTP request, the document is fetched and displayed in the same page.

§ The last approach is to open a new window and display the document in the window.

We’ve taken on a large challenge today, so let’s get cracking!

Test Harness

Our first step is to build a small test program to have a document available to display. As we don’t feel like generating PDF documents on the fly or reading images from some database table, we’ll just upload the test document. In all cases, we assume that either an image (.jpg, gif or .png) or some “known” document (.pdf, .doc, .xls, etc.) is specified.

After the document is uploaded, we have it “in our hands” and must do something with it. Keep in mind that after the response is processed, our session will be closed (stateless program).

First, we create a new BSP application and add a few page attributes:

file_length TYPE STRING
file_mime_type TYPE STRING
file_name TYPE STRING
file_content TYPE XSTRING
display_type TYPE STRING
display_url TYPE STRING

The four file_* attributes reflect the dynamic document that we “created” via an upload. Note that the content is of type XSTRING because we are working with binary documents.

For Complete Details :

Download this file

Other related Link :

Download Advance BSP programming Tutorial

Leave a comment