29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Important: If you are using the Online Catalog sample from the <strong>IBM</strong><br />

<strong>Redbooks</strong> site, you will notice that the FeaturedItemXMLServlet contains<br />

additional lines of code for the xslContent string. We did this because we<br />

wanted to incorporate our template into the HTML output.<br />

Importing the SQLToXML jar file<br />

At runtime, the SQLToXML jar file will be needed to access objects in the servlet.<br />

To be available, it needs to be placed in the WEB-INF\lib folder of the project.<br />

1. Open the Web perspective.<br />

2. While in the Project Navigator view navigate to the<br />

OnlineCatalog/WebContent/WEB-INF directory and select the lib folder.<br />

3. Select File > Import from the main menu and then select File system from<br />

the Import dialog.<br />

4. Click Next.<br />

5. Browse to<br />

\wstools\eclipse\plugins\com.ibm.etools.sqltoxml_5.1\jars.<br />

6. Click OK.<br />

7. Expand the jars tree, then select the sqltoxml.jar check box.<br />

8. Set the destination folder to be OnlineCatalog/WebContent/WEB-INF/lib.<br />

9. Click Finish. The JAR file appears in the<br />

OnlineCatalog/WebContent/WEB-INF/lib directory. Your application server will<br />

need to be restarted before your changes take effect.<br />

Step 6: Adding a page to the Web site diagram<br />

With the FeaturedItemXMLServlet servlet completed, we can add a link to the<br />

index.html page of our application that will call the servlet and then output the<br />

featured item list.<br />

1. Open the Web perspective.<br />

2. Expand the OnlineCatalog project and open the Web site diagram editor by<br />

double-clicking Web Site Configuration.<br />

3. Right-click the index.html page diagram icon and select Add New Page -> As<br />

Child from the context menu. This adds a new page icon to the diagram.<br />

4. Change the Navigation Label from newpage to Featured Item.<br />

5. Double-click the Featured Item page diagram icon and enter the page value of<br />

FeaturedItemXMLServlet. This is the URL mapping value that we specified<br />

when the servlet was created.<br />

Chapter 10. Working with XML 351

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!