wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP Templating methodology Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Templating methodology" Watch "JSP Templating methodology" New topic
Author

JSP Templating methodology

Clifford Adams
Ranch Hand

Joined: May 12, 2004
Posts: 50
I'm curious about different jsp templating implementations. I've decided that I don't want to go with a system like velocity or sitemesh. I want to do it using simple c:import's. There seems to be two schools of thought on this: do it like SSI's or do it like Smarty (the PHP templating system)

SSI:
Each page has the same structure and imports the common parts from other files.

Smarty:
You define what makes this page unique, then apply a template to it. dynamic stuff would be passed to the c:import via params.


I'm leaning towards the smarty approach for it's centralization. Any template changes only need to be made in 1 place.

Opinions?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

3) Use JSP custom actions


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Clifford Adams
Ranch Hand

Joined: May 12, 2004
Posts: 50
Care to expound a little?

What is the value in writing a custom tag library over using jstl?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Using that technique, my pages tend to look like:



The <whatever:body> action is implemented via a JSP tag file that emits all the template stuff and embeds the page-specific content in the appropriate location.
Clifford Adams
Ranch Hand

Joined: May 12, 2004
Posts: 50
ahhh. I had completely forgotten about tag files.

//off to do some reading
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
You might take a look at struts:tiles.
Why re-invent the wheel?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Originally posted by Stefan Evans:
Why re-invent the wheel?


To me, adopting tiles just to do simple templating is bit like using



when all you need is a wheel.
Clifford Adams
Ranch Hand

Joined: May 12, 2004
Posts: 50
I've looked at tiles, but it doesn't do anything c:import can't

the tag files look nice and flexible.

thanks.
 
jQuery in Action, 2nd edition
 
subject: JSP Templating methodology
 
Similar Threads
Application is executing correctly but getting these exception in log
about jsp... and about not using one
Template Engine exist like this?
A few questions of a beginner
Template Engine