views:

932

answers:

4

I want to use a template engine in a struts application and would like to know if using TILES can be recommended instead of FREEMARKER or VELOCITY.

+4  A: 

I've used tiles before on a project. It was good for templating, however it can't really be compared to velocity or freemarker: with Tiles you use normal JSPs and are limited to the JSP tags youv'e got.

Velocity (and probably Freemarker although I haven't used it before) provide their own tags or expression language, so you can do thinks like:

Hello ${name}

Which you can't do in plain JSPs. [updated due to comment: in JSP 2.0, EL is included so you can do things like that. However, I think Velocity or Freemarker are more powerful in terms of what you can do with it.]

If you've got a layout with lots of different components (i.e. header, sidebar, etc) and you want to define various different templates, tiles isn't a bad choice. (Although be warned - it can be quite a lot of XML!)

But if you need something more "advanced" than plain JSPs Velocity or Freemarker might be the way to go.

Phill Sacre
Expression Language has been part of the JSP specification since 2.0, so you can do that in plain JSPs.
insin
Ok, although I don't think the JSP EL is as powerful as what you can do with Velocity or Freemarker.
Phill Sacre
+2  A: 

I use tiles and velocity.

Tiles is great for dividing a page in components and reuse markup between screens while velocity is a great template language such smarty in the php world.

I recommend not to choose between tiles and velocity but instead use both. They complement each other really well.

Sergio del Amo
+1  A: 

Or you could use Stripes. MUCH easier than Tiles!

CJones
A: 

has anyone implemented struts tiles and velocity together?

Michael