Problems with "a" tags

Splash Forums Rewrite Users Problems with "a" tags

This topic contains 12 replies, has 3 voices, and was last updated by  Will Durman 8 years, 7 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
  • #23773

    Will Durman

    I installed rewrite a few days ago and have found it very useful. I am using JSF 2.1, and links generated by h:link work fine.

    However, for some reason any plain a tag now fails, resulting in a 404 Page Not found error. If I remove the rewrite-servlet-2.0.0.Final.jar, then the a tags works as normal.

    A sample a tag I’m using is:

    a href=/sites/#{repManagerBean.rep.webSiteAlias}/public/content/jewelry/looksList.jsf

    The URL of the link appears to be completely normal, when viewing the page source in the browser.

    I only have one rule currently, and this rule has a logger included. The rule is not picking up the above a tag.

    So, it would appear that the normal flow of URL resolution is being disrupted. Is there a debug mode or something similar for rewrite I can use to find out how my links are failing?

    • This topic was modified 8 years, 8 months ago by  Will Durman.
    • This topic was modified 8 years, 8 months ago by  Will Durman.
    • This topic was modified 8 years, 8 months ago by  Will Durman.


    first of all: Could you please update to 2.0.1.Final? We released this version a few days ago and it contains many important bugfixes.

    So you say the a links don’t work any more? Actually Rewrite doesn’t (and cannot) modify links that you manually add to your page using plain a links. What happens if you manually type such an URL into the browser address bar?

    Could you please also post your Rewrite rules. It would be interesting to know how they look like.


    Will Durman

    The single rule I have is:

       .perform(Log.message(Logger.Level.INFO, "Joining on /products/{productGroupId}"))

    In fact, h:outputLink tags do not work. Only commandButtons, commandLinks and h:links (which are correctly joined by the rule) are working right now.

    If I manually enter a URL, I get a 404 error. If I remove the rewrite jar and entry from the build path, then URLs work as normal. We do use three filters on the site, but I have stepped through them and nothing seems amiss.

    Thank you for your quick response. I am updating to 2.0.1 right now and will post if there is an improvement.

    • This reply was modified 8 years, 8 months ago by  Will Durman.

    Will Durman

    I updated to 2.0.1 and am still experiencing the same issue with links.

    I will search through my server log and see if I can find any additional clues.


    Will Durman

    One of the filters on my site do a forward at the end of doFilter:

    httpRequest.getRequestDispatcher(requestPath).forward(httpRequest, httpResponse);

    The requestPath can be altered during the course of the filter, and it appears that after this forward everything breaks down. I know there’s a warning to disable the use of other URL rewriting mechanisms, but did not think this filter would be an issue.

    It’s my understanding that rewrite happens after other filters. Is there a way to make rewrite more selective? Rewrite fits my needs perfectly so I am hopeful I can find a solution. Thank you!


    Hi there,

    I have a general understanding of the problem you are experiencing, but it is difficult to determine the root problem without more information.

    Is it possible that you could upload a sample application that reproduces the problem?

    This would help us determine the root cause.



    Will Durman

    I knew this moment would come, that I would need to upload a sample application. I will work on it, but I do have a hopefully quick question. Is there a way to make the rewrite filter happen before my other filters?

    FYI, I added an additional rule to just log all requests intercepted by my HttpConfigurationProvider. When my request is forwarded on by this line, at the very end of my doFilter

    httpRequest.getRequestDispatcher(requestPath).forward(httpRequest, httpResponse);

    The requestPath might be something like:


    However, in from the logging statement in my catch-all rule:

    11:40:25,805 INFO [org.ocpsoft.rewrite.config.Log] (ajp-localhost/ Client requested path: will.durman/public/content/jewelry/looksList.jsf

    So this bit will.durman of the requestPath is back in the request. Am I doing something wrong?

    • This reply was modified 8 years, 8 months ago by  Will Durman.
    • This reply was modified 8 years, 8 months ago by  Will Durman.

    You could also try to reproduce it with an existing application. Rewrite ships with a JSF sample application called Rewrite Bookstore. You will find it here:

    If you want more control over the filter ordering, you could simply copy&paste the relevant part of Rewrite’s web-fragment.xml directly into your web.xml:

          <filter-name>OCPsoft Rewrite Filter</filter-name>
          <filter-name>OCPsoft Rewrite Filter</filter-name>

    In this case you can place it anywhere you want.


    Will Durman

    Ahh, I had not run across manual web.xml configuration in any of the documentation yet. So I can restrict the filter now to /products/*, which lets the inbound join happen, and the other “a” and “h:outputLink” links work as usual. Perfect!

    Except, I lose the join “magic”, as in, the links that match my “to” path are not automatically rewritten.

    Thank you, this will get me going, and I will try to replicate the problem using the bookstore app as you suggested.

    • This reply was modified 8 years, 8 months ago by  Will Durman.

    Will Durman

    Using the filter-mapping as-is (with <url-pattern>/*</url-pattern>), and moving the filter declaration to the top of the list in web.xml, has fixed everything. Thanks again.


    Will Durman

    I am still experiencing a bit of a problem with filters. I moved the OCPsoft Rewrite Filter filter mapping to the top of my list. However, once a request hits the Rewrite filter, it does not appear any of my other filters catch the request.

    For example, with this rule:

    .addRule(Join.path("/{webSiteAlias}/shop-by-look").to("/{webSiteAlias}/public/content/jewelry/looksList.jsf")).perform(Log.message(Logger.Level.INFO, "Join /{webSiteAlias}/shop-by-look"))

    The join is logged, but the request is not caught by any other filter.

    I have downloaded the file from GitHub and I’m trying to figure this out in the source. Does the Rewrite filter call doFilter(request, response) when it’s finished processing?


    You have to add <dispatcher>FORWARD</dispatcher> to your other filters, because Rewrite intercepts the “virtual” URLs and forwards the request to the physical server resource. But forwarded requests are only processed if the filter configuration contains <dispatcher>FORWARD</dispatcher>.

    If this doesn’t help, please post your web.xml.


    Will Durman

    I had just logged in to post this same solution! You beat me by five minutes. My existing filters had no dispatchers specified. I have now added REQUEST and FORWARD dispatchers to all of my filters and working as intended. Thank you for the quick response, once again.

Viewing 13 posts - 1 through 13 (of 13 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.