servletsstruts2tuckey-urlrewrite-filter

How to access pretty URL from code


I am using UrlRewriteFilter to make my URLs pretty. From within my application I frequently need to access the current URL. I do it like this:

ServletActionContext.getRequest().getRequestURI();

However this gives me the ugly version of the URL. How can I access the pretty URL before it is turned into ugly one by UrlRewriteFilter?


Solution

  • I have found this solution here.

    This worked for me:

    ServletActionContext.getRequest().getAttribute(
                "javax.servlet.forward.request_uri");