Why Search Engine Optimization?


You have a web site. How do you get your web site noticed by your potential customers?  When people search key words in Google, Bing or Yahoo, it is vital for your web site to rank high in search engines to attract visitors and turn visitors into leads and sales.

One vital SEO component is friendly URL.  Unfortunately the default Seam URL is not SEO friendly.


Here is one example of Seam URL:


Here is an example of SEO friendly URL:



What is Tuckey URL Rewrite?


UrlRewriteFilter is a Java Web Filter for any J2EE compliant web application server, which allows you to rewrite URLs before they get to your code.  Developers can specify the inbound and outbound rules in the urlwrite.xml file.

In the following example, requests for /world/usa/nyc will be transparently forwarded to /world.jsp

        <name>World Rule</name>



Configure Seam Application to use Tuckey URL Rewrite


It is actually very easy. Just add the following lines to your web.xml file. Please look the Seam Bay application in Seam examples folder.

<!-- URL Rewrite Filter -->










How to create SEO friendly links?


Seam bay is already configured to use UrlRewrite filter. So I made some modification to the home.xhtml. I used <h:outputLink> to expose category as SEO friendly links. 


  <ui:repeat id="categories" value="#{categories}" var="cat">      

<h:outputLink value="#{facesContext.externalContext.requestContextPath}/category/#{cat.name}">





Seam Bay.jpg



How to process SEO friendly links?


Step1: add an inbound rule rewrite rule in the urlrewrite.xml.




     <to last="true">/search.seam?categoryName=$1</to>


Urlrewrite will then rewrite http://localhost:8080/seam-bay/category/Books to: http://localhost:8080/seam-bay/search.seam?categoryName=Books


Step2:  modify pages.xml to handle URL parameters

<page view-id="/search.xhtml" >

  <param name="categoryName" value="#{auctionSearch.bookMarkCategoryName}"/>



Step 3:   modify AuctionSearch.java


private String bookMarkCategoryName;

public String getBookMarkCategoryName()


      return bookMarkCategoryName;


   public void setBookMarkCategoryName(String categoryName)


      List<Category> children = entityManager.createQuery(

            "from Category c where UPPER(c.name) = :name")

            .setParameter("name", categoryName.toUpperCase() )









You are done.