In my website I have a master JSP template:
<html>
<body>
<nav>...</nav>
<tiles:insertAttribute name="body" />
<footer>...</footer>
</body>
</html>
And multiple page templates:
<p>This is content</p>
Now I'd like the page templates to be able to define some Javascript and CSS includes, so the page templates must be executed before the <head>
of the master template.
In PHP I could use output buffering for this:
<? ob_start()
include $slave;
$body = ob_get_clean(); ?>
<html>
<head>
<? foreach($javascripts as $script) ?>
<script src="<?=$script?>" />
<? endforeach ?>
<body>
<nav>...</nav>
<?=$body?>
<footer>...</footer>
</body>
</html>
Is there a similar technology available in JSP? Or else another way to achieve what I need? I'm using it in Spring MVC 3 + Apache Tiles