Sun Java System Web Server 6.1 SP9 Administrator's Guide

Customizing the Search Results Page

Search results are generated as follows:

You can customize the search results page simply by changing the attribute values of the tags.

The following sample code starts with a title bar, and then displays a number of records as specified, and finally, a navigation bar. The title bar contains the query string used in the search along with the range of total records returned, for example, 1– 10. For each record, the records section shows the title with a link to the file, up to three passages with keywords highlighted, the URL, the date of creation, and the size of the document.

At the end of the section, the navigation bar provides links to the previous and next pages, as well as direct links to eight additional pages before and after the current page.

<s1ws:formAction >
<s1ws:formSubmission success="true" >
    <s1ws:search scope="page" >
    <!--search results-->
    (...html omitted...)
        <s1ws:resultStat formId="test" type="total" ></b> Results 
Found, Sorted by Relevance</span></td><td>
        <span class="body"><a href="/search/search.jsp?">Sort by 
        <td align="right"><span class="body">
        <s1ws:resultNav formId="test" type="previous" caption="<img 
border=0 src=\"images/arrow-left.gif\" alt=\"Previous\">" >
        &nbsp;<s1ws:resultStat formId="test" type="range" >
        &nbsp;<s1ws:resultNav formId="test" type="next" caption="<img 
border=0 src=\"images/arrow-right.gif\" alt=\"Next\">" >
        &nbsp; <!img alt="Next" src="images/arrow-right.gif" 
border="0" WIDTH="13" HEIGHT="9">
            (...html omitted...)
        <table border=0>
        <s1ws:resultIteration formId="test" start="1" results="15">
            <tr class=body>
                <td valign=top>
                <s1ws:item property=’number’ >.&nbsp;&nbsp;
                    <b><a href="<s1ws:item property=’url’ 
>"><s1ws:item property=’title’ ></a></b>
                    <s1ws:item property=’passages’ >
                    <font color="#999999" size="-2">
                    <s1ws:item property=’url’ > -
                    <s1ws:item property=’date’ > -
                    <s1ws:item property=’size’ > KB
        (...html omitted...)
        <s1ws:resultNav formId="test" type="previous" >
        <s1ws:resultNav formId="test" type="full" offset="8" >
        <s1ws:resultNav formId="test" type="next" >
    (...html omitted...)

The following figure shows the customized search results page:

Figure 18–4 Customized Search Results Page

Customized Search Results Page

The basic search result interface can be easily customized by manipulating the tags and modifying the HTMLs. For example, the navigation bar may be copied and placed before the search results. Users may also choose to show or not show any of the properties for a search record.

Besides being used along with a form, the <search>, <resultIterate> and related tags may be used to listed specific topics. The following sample code lists the top ten articles on Java Web Services on a site:

<s1ws:search collection="Articles" query="Java Web Services" >
<table cellspacing="0" cellpadding="3" border="0">
  <tr class="Title"><td>Java Web Services</td></tr>
<table cellspacing="0" cellpadding="3" border="0">
<td><a href="<s1ws:item property=’URL’ >"> <s1ws:item property=’Title’></a></td>