wood burning stoves 2.0*
The moose likes Struts and the fly likes tiles:insert vs jsp:include - Templates? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "tiles:insert vs jsp:include - Templates?" Watch "tiles:insert vs jsp:include - Templates?" New topic
Author

tiles:insert vs jsp:include - Templates?

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Is one really better than the other? Or maybe I should say, what does Tiles do for me that jsp by itself won't allow?
I am looking for a good templating style to really seperate my html from my logic. So that my web app can be customized really easily without someone screwing with the complex code.
PHP uses several but the one I have used is called Smarty. I have looked at the Tiles syntax and API and I am initially not that impressed with it. It seems that I can do the same things with pure jsp just as easily.
Am I wrong?


GenRocket - Experts at Building Test Data
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303

Is one really better than the other? Or maybe I should say, what does Tiles do for me that jsp by itself won't allow?

Hi Greg,
The selling point of Tiles for me is threefold:
1. I can specify my Tiles layout in the tiles-def.xml file. Thus, apart from creating JSP pages for the base-level include files, I can stick to working with the tiles-def.xml file and let Struts worry about creating the layout JSP files.
2. The JSP Tile files created by Struts are cached by the servlet for nice performance.
3. The tiles-def.xml file allows for hierarchical overloading of tiles. For instance, if I have a base layout A that includes three tiles x, y, and z, then I can create another layout B that subclasses layout A, such that tiles x and y are included in layout B but tile z is overloaded with another tile w. I find this tremendously useful -- not only because it allows me to create hierarchical relationships between JSP pages but because I can use the tile breakdown to create corresponding Value Objects and so better align my JSP pages with my codebase.

I am looking for a good templating style to really seperate my html from my logic. So that my web app can be customized really easily without someone screwing with the complex code.

That's where tiles-def.xml comes in.

If you search my previous posts you should find one or two of them that refer to a free downloadable PDF version of Manning's Struts chapter on Tiles. It is an excellent read and explains how to use the XML-based hierarchical features of Tiles.
I hope this is helpful.
Darryl
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Thanks Darryl. Very good response. I will definattly check on the pdf you mentioned.
Thanks a bunch!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tiles:insert vs jsp:include - Templates?