Rewrite with Deltaspike

Splash Forums Rewrite Users Rewrite with Deltaspike

This topic contains 8 replies, has 5 voices, and was last updated by  fabmars 1 year, 9 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #26407

    dave
    Participant

    I’ve been trying to implement rewrite with Deltaspike but it’s only working on inbound url’s.
    In my access.log I’m trying to access the url ‘/ds/about’ which then does a redirect to ‘/ds/about.xhtml’ to the url in the address bar is always changes to the .xhtml version.

    Here’s the access.log snippet:
    127.0.0.1 – – [28/Sep/2014:16:29:46 +1000] “GET /ds/about HTTP/1.1” 302 –
    127.0.0.1 – – [28/Sep/2014:16:29:46 +1000] “GET /ds/about.xhtml?dswid=6616 HTTP/1.1” 200 6854

    pom.xml:
    <dependency>
    <groupId>org.ocpsoft.rewrite</groupId>
    <artifactId>rewrite-servlet</artifactId>
    <version>2.0.12.Final</version>
    </dependency>

    Configuration:
    @Override
    public Configuration getConfiguration(final ServletContext context)
    {
    return ConfigurationBuilder.begin()
    .addRule(Join.path(“/about”).to(“/about.xhtml”));
    }

    #26408

    dave
    Participant

    After experimenting I’ve found that this is only an issue on an initial GET request when a redirect is issued to put the ‘dswid’ parameter on the url. Disabling the multi-window handling (http://deltaspike.apache.org/documentation/jsf.html#_switch_mode) prevents the redirect and url rewrite works fine after this. Any ideas how to get url rewriting working without disabling multi-window handling?

    #26429

    Sorry for the delay response.

    I guess DeltaSpike isn’t calling HttpServletResponse.encodeURL() on the target URL before sending the redirect. That is the hook used by Rewrite to perform outbound rewriting. So this is something that should be fixed in DeltaSpike. As I’m on the DeltaSpike team, I’ll have a look at this early next week.

    Thanks a lot for reporting this.

    #26445

    bernhard
    Participant

    Hi!

    I found this in org.apache.deltaspike.jsf.impl.util.ClientWindowHelper#handleInitialRedirect. If no dswid is provided, the initial redirect happens without rewriting the url.

    I think something like:
    url = ((HttpServletResponse)externalContext.getResponse()).encodeURL(url);
    externalContext.redirect(url);

    could do the trick. This worked but I’m not sure if there are other parts involved…

    Best regards,
    Bernhard

    #26462

    That is definitely a workaround, but ideally the framework should be doing this for you automatically. I think @chkal is right in that regard.

    #26500

    @dave & @bernard:

    Sorry for the delayed response. Could you perhaps create a corresponding issue in the DeltaSpike JIRA? This would be really helpful.

    https://issues.apache.org/jira/browse/DELTASPIKE

    Thanks

    #26502

    bernhard
    Participant
    #26506

    Awesome, thanks!

    #26508

    fabmars
    Participant

    Oh, great, I had the same issue.

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

You must be logged in to reply to this topic.

Comments are closed.