I am developing a Java EE project (used EJB3, JSF and maven) running on JBoss AS 4.2.x.GA app server.
I want to rewrite my URLs while passing param values between pages.
For instance, when user clicks a submit button, some params are added to the end of the URL; however I want it to be more clear like:
../testApp/testPage/12 instead of ../testApp/testPage.jsf?id=..
How to achieve that?
The most used solution with Java is URLRewrite Filter .
The newer versions also have syntax that looks very similar to the very wide used and known “mod_rewrite” one (since this is what most apache httpd based servers use).
You can find documentation and examples there, and many of the solutions on the google group too – since what you mention in your question is a very a common requirement for many applications.
Also please note that you might need both inbound and outbound rules for rewriting too (you’ll find examples there), as URLRewrite Filter can’t automatically calculate “the inverse” of a rewrite expression.
For rewriting solutions in general, if a user is not quite fluent with regular expressions, than it would make sense to install in the favorite IDE some sort of RegExp plug-in to try those rewrite expressions first (it saved me allot of time in the past 🙂 ).