Simple question – remove prefix from URLs

Splash Forums Rewrite Users Simple question – remove prefix from URLs

This topic contains 9 replies, has 2 voices, and was last updated by  Lincoln Baxter III 3 years, 1 month ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #24164

    Oleg
    Participant

    Hello,

    I have a simple question, but can not find a solution. Assume, all my XHTML files are located in webapp under the folder “mod”. I would like to avoid the need to type /mod/… in URLs. How can I rewrite URLs with the Rewrite, so that all requests get a prefix “mod” when resolving against real paths? For instance, when somebody types as URL

    .../views/list.jsf

    it should be resolved (mapped) to

    .../mod/views/list.jsf

    I’ve tried with

    public Configuration getConfiguration(ServletContext context)
    {
        return ConfigurationBuilder.begin().addRule(Join.path("/{tail}").to("/moda/{tail}")).where("tail")
                                   .matches(".*");
    }

    but no luck. Can one help me? Thanks in advance and sorry for this stupid question.

    #24165

    Oleg
    Participant

    What I get as result for this mapping is 404. Furthermore, I see URLs like this one

    http://localhost:8080/WebPortal/index.html?windowId=51b&page=index.html&page=index.html

    windowId is CDI specific. That’s ok. But twice page=index.html is something weird. Is this caused by Rewrite?

    #24166

    Oleg
    Participant

    I found that there is a problem even without Configuration when Rewriter with JSF und CDI modules is in the classpath. We get logged in Principal object from the request object. Principal object is put into HttpRequest by a special security filter. When Rewriter with JSF / CDI modules is added to the project (only dependencies), the Principal object is null (and we get NPE). Any ideas?

    • This reply was modified 3 years, 2 months ago by  Oleg.
    #24168

    Oleg
    Participant

    Solved by configuring RewriteFilter manually in web.xml as a first filter, before all other filters. This takes precedence over web-fragment.xml in Rewrite JAR file.

    #24197

    Hey Oleg,

    Thanks for posting your solution. I’m sorry you had trouble, but glad you got it figured out!

    ~Lincoln

    #24205

    Actually, I think this is a bug with the CDI integration that we may need to work on. CDI BeanManagers are tricky to get a hold of 😉

    #24209

    Oleg
    Participant

    Yes, I think this is a bug with CDI integration.

    It works with PrimeFaces <p:button …/> (full page GET request).
    It works with <p:commandButton …/> (AJAX request per default)
    It DOESN’T WORK with <p:commandButton ajax=”false” …/> (full page POST request).

    In the third case I can see added windowId with every full page POST request. E.g. after 3 requests:

    http://localhost:8080/WebPortal/index.html?windowId=51b&windowId=51b&windowId=51b&windowId=51b

    #24213

    When you say it doesn’t work, what is the problem exactly?

    Is the problem the extra parameters, or is the problem something that is actually technically not working at all?

    ~Lincoln

    #24215

    Oleg
    Participant

    It works fine technically. Extra CDI parameters are annoying :-). I could avoid Rewrite parameters (in the example &page=index.html&page=index.html) by adding rules without binding (you know what I mean), but CDI parameters are still here.

    #24219

    Could you upload a sample app that reproduces this on an EE appserver like JBoss/Wildfly/GlassFish ? Or even better, write a Rewrite test case? Either one.

    I’d like to dig into this a bit deeper.

    Thanks,
    Lincoln

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

You must be logged in to reply to this topic.

Comments are closed.