Return to Home Page

Tutorial: Using JavaServer Pages with WebWorks Publisher

If you use WebWorks Publisher to create HTML-based output from your FrameMaker documents, you can add JavaServer Pages (JSP) functionality to your HTML output.

By DAVID CASTRO
Unaffiliated

 

There are four sets of steps for adding functionality to your HTML output that lets your end-users determine what content they want to view. This is similar to the conditionalize text feature in FrameMaker, but dynamic.

Adding a JSP Conditional Tag to FrameMaker

Use the following steps to add a JSP conditional tag to a FrameMaker document:

  1. Create a JSP conditional tag library. You can do this on my Web site (jsp.davidcastro.com/tagbuilder.jsp).

  2. Open a FrameMaker source document.

  3. Click Special —> Conditional Text. The Conditional Text window opens.

    FrameMaker Conditional Text window

  4. Click Edit Condition Tag. The Edit Condition Tag window opens.

    FrameMaker Edit Condition Tag window

  5. Set the name, style, and color of the tag. Set the tag text color to a different color than the text in the FrameMaker source document. Click Set.

    Note: Setting the tag text color makes it easy for you to differentiate text in your FrameMaker document that is conditionalized using the tag from text that is not conditionalized.

  6. Identify a section of your FrameMaker file that has content that you want to be visible only to a select type of end-user.

    For example, the following sample document has two colored segments representing two FrameMaker conditional tags. The blue segment of text is conditional text for end-users in the Radiology department of any hospital. The green segment of text is conditional text for end-users in the Radiology department of St. Luke Hospital. To view the green text, an end-user must match both conditions before the text is displayed.

    Sample showing two segments of conditionalized text.

  7. Add the appropriate JSP tags in the content to conditionalize it. You can learn the JSP tagging code when you create the conditionalization tag library on my Web site.

    Sample showing JSP tags applied to text segments.

  8. Apply the condition tag that you created in steps 3–5 to the JSP tags:

    Sample showing FrameMaker conditionlized tags applied to the text segments.

  9. Import the condition tag that you created in steps 3–5 into your other FrameMaker source files.

  10. Repeat steps 6–8 for all other conditionalized content in your FrameMaker files.

Setting WebWorks Publisher to Process JSP Code

You must set up WebWorks Publisher so that it does not display the JSP content that is marked with the JSP condition you just created. Instead, WebWorks Publisher puts the JSP content into the output files as is.

Use the following steps to set WebWorks Publisher to properly process JSP code:

  1. Open the WebWorks Publisher project for the FrameMaker files that you modified.

  2. Right-click on the project folder and click Properties from the pop-up menu. The File Properties window opens.

    WebWorks Publisher File Properties window

  3. Click the Conditions tab.

  4. Click the condition that you created for JSP code in the Show these Conditions list box.

  5. Click the Use pass through character mappings for this condition check box.

  6. Click OK.

Adding JSP Tag Library Capabilities to Your Output

You must set up your page.asp file so that code is added to each HTML file that is output. Each page must have this code in order to use the JSP tag library you created.

Use the following steps to add JSP tag library capabilities to your output:

  1. In WebWorks Publisher, double-click the page.asp icon to open the file in an external editor.

  2. At the top of the file, add the JSP syntax necessary to link the tag library you created to the file. The syntax looks similar to the following:

    <%@ taglib uri="WEB-INF/tlds/companyname.tld" prefix="cond" %>

  3. Save the page.asp file.

Post-Processing your HTML or XML Output

Finally, using this technique does require some post-processing. Fortunately, you can automate the post-processing.

When you examine your output, you will notice the following:

  • The JSP tags that you placed around paragraphs reside between the <p> and </p> tags.

  • The tags that you placed around content in tables are between the <td> and </td> tags.

If you leave the tags as they are generated, you will end up with empty paragraphs and empty table rows.

Instead, you likely want the conditionalized paragraphs completely removed and the empty table rows to disappear. To do this, you must use a search and replace tool (for example, a grep tool) to go through your files and change the order of elements in your HTML code.

The following steps show you all of the post-processing steps you need to perform. The search and replace tool that I use, and for which I provide grep syntax, is called Search and Replace and is distributed by Funduc Software.

Use the following steps to post-process your HTML or XML output:

  1. Generate HTML or XML output from your WebWorks Publisher project.

  2. Use your search and replace tool to find files that use the JSP tag library to conditionalize content. Search for the string <cond:.

  3. For each of the files that contain a JSP tag, change the file extension from .html or .htm to .jsp. This step is necessary so that your Web server knows to execute code in the files. If you skip this step, the code does not execute but is downloaded into Web browsers. While this doesn’t cause errors, it isn’t what you want to accomplish.

  4. Use your search and replace tool to search through all of the HTML and JSP files for links to the files that you renamed, and change those links to point to the new filenames.

  5. Use your search and replace tool to change the order of elements in your JSP files. The following are syntax that you would use in the search and replace tools that I use, if the JSP tag library component that you created conditionalized based on departments:

    • change <li class*<p><cond:dept*>
      to \<cond:dept%2\>\<li class%1\<p\>

    • change </cond:dept></p></li>
      to \</p\>\</li\>\</cond:dept\>

    This particular search and replace changes the following code:

    <li class="SmartList1"><a name="32063"> </a><p><cond:dept dept="radiology">All Radiology personnel must ... </cond:dept></p></li>

    to this:

    <cond:dept dept="radiology"><li class="SmartList1"><a name="32063"> </a><p>All Radiology personnel must ... </p></li></cond:dept>

    Additional grep syntax is available on my Web site.

  6. Copy your output into an appropriate directory on your Web server and access one of the files that uses the tag library component.

David Castro works from his home outside of Charleston, South Carolina. When he is not working as a Senior Information Developer for his telecommuting job at CrossAccess Corporation, based in Santa Clara, California, he is pretending to be a programmer by developing JSP tag libraries. He is married and has a 6-year-old daughter and twin boys that were born in mid-August.

Moving TC Online JavaServer Pages for Technical WritersUsing JSP with WebWorks Publisher
Practical MagicReluctant TrainerWeb ReviewBook Review
Resources & References
Home


Fall 2001 (Volume 4, #4)

Copyright © 1998, 2002 Society for Technical Communication