Re: Rewrite every *.jsf

Splash Forums PrettyFaces Users Rewrite every *.jsf Re: Rewrite every *.jsf

#20593

mraible
Participant

I’m trying to do something similar – where every request that comes through tries to forward to *.jsf (if there isn’t a previous mapping that forwards it to a different resource). With the UrlRewriteFilter, I’m almost able to accomplish what I want using the following:

<rule>

<from>/</from>

<to type="redirect" last="true">mainMenu</to>

</rule>

<rule>

<from>/j_security_check</from>

<to>/j_security_check</to>

</rule>

<rule>

<from>/images/**</from>

<to>/images/$1</to>

</rule>

<rule>

<from>/scripts/**</from>

<to>/scripts/$1</to>

</rule>

<rule>

<from>/styles/**</from>

<to>/styles/$1</to>

</rule>

<rule>

<from>/login*</from>

<to>/login.jsp</to>

</rule>

<rule>

<from>/logout*</from>

<to>/logout.jsp</to>

</rule>

<!-- Struts -->

<rule match-type="regex">

<from>^([^?]*)/([^?/.]+)(?.*)?$</from>

<to last="true">$1/$2.jsf$3</to>

</rule>

<outbound-rule match-type="regex">

<from>^(.*).jsf(?.*)?$</from>

<to last="false">$1$2</to>

</outbound-rule>

However, I’ve run into an issue where UrlRewriteFilter intercepts a post on my File Upload form and doesn’t submit it to my managed bean properly. So I’ve turned to Pretty Faces in hopes of getting something similar setup.

Here’s what I have so far:

<rewrite match="^/login$" substitute="/login.jsp" redirect="chain"/>

<rewrite match="/$" substitute="/mainMenu" redirect="302"/>

<rewrite match="^([^?]*)/([^?/.]+)(?.*)?$" substitute="$1/$2.jsf$3" redirect="chain"/>

Unfortunately, this results in the following, which I’m guessing is caused by a continuous redirect.

2011-01-28 07:58:49.761:WARN::Error for /mainMenu

java.lang.StackOverflowError

at java.util.HashMap.removeEntryForKey(HashMap.java:548)

at java.util.HashMap.remove(HashMap.java:538)

at org.mortbay.util.AttributesMap.removeAttribute(AttributesMap.java:51)

at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.setAttribute(Dispatcher.java:441)

at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.removeAttribute(Dispatcher.java:461)

Does Pretty Faces have the ability to say “last” on a rewrite rule and forward from there w/o processing again?

Thanks,

Matt