The NetBeans IDE is a great tool for doing Java EE development. One feature that I think is overlooked is the ability to refactor your XHTML pages into composite components. The video below demonstrates how to do it. The code was developed using NetBeans IDE and GlassFish.
The cleaned up and more polished code is provided for your enjoyment: sample-composite-component-demo.zip