Today I want to tell you about the new Rewrite 2.0 release. Not heard of Rewrite yet? Um, maybe PrettyFaces? Well…ok, let me shortly introduce you to this stuff.
## What is it?
PrettyFaces is THE framework to make your urls look nice and clean(a.k.a REST style URLs). It works in a Servlet environment and you can configure it via XML or Annotations. You can also serve different files via the same url depending on certain conditions. PrettyFaces exists since several years and I have successfully used it in multiple projects. Its just great.
Although it works very smooth, there are some pitfalls: You can´t use PrettyFaces, as the name says, in other environments like GWT or Wicket and the rules are more or less unflexible. You can´t have overall rules that evaluate at runtime like a login-required rule for a subset of URLs, etc.
Thats what the supercool developers [+Lincoln Baxter, III](http://plus.google.com/115038964212095419692) and [+Christian Kaltepoth](http://plus.google.com/105317683054583400251) also noticed and they wanted to take it further. They wanted to build THE ultimate rewriting framework and they made it! **Rewrite was born.**
## What can I do with it?
Short answer: Awesome stuff!Long answer:Dynamic mapping of URLs to resourcesExecute actions during page-loadExtract and process URL fragmentsExtract URL parametersUse CDI, Spring, etc.Use Transformers to for example dynamically transform .less into .css filesUse Caching mechanisms when neededDynamically return HTTP Codesetc…
## What about the ‚old‘ PrettyFaces?
PrettyFaces as a product will be dead! Yes, DEAD! Because, the developers want to uniform things which is a very good point. But because they are not mean to other developers they added a cool module: rewrite-config-prettyfaces. With this module, you can just use the old configuration with the new Rewrite 2.0 and seamlessly migrate to it.
## Migrating from PrettyFaces to Rewrite
Do you already know how to migrate? If not, just follow my simple example with running source-code hosted on #Github: http://ocpsoft.org/java/migrating-from-prettyfaces-to-rewrite-simplicity-meets-power/I wrote this article over a year ago for the first versions of Rewrite and now again updated the source-code to use Rewrite 2.0. Thanks to +Lincoln Baxter, III for fine-tuning my post.I hope you enjoyed this post and learned something new. Now go out and make your URLs more beautiful and secure.