JSP Component Creation
- by jboyd
When creating JSP pages one thing that I'd often like is the ability to do something like this:
<jsp:include page="fancystoryrenderer.jsp" value="${aStoryObjectInMyModel}/>
...
fancystoryrenderer.jsp
<div id="fancymainbody">
...
${theStory.title}
...
</div>
The main important characteristics of this is that I can reuse the same component on the same JSP page in different places without having to copy paste the component and give the story variables different names, notice that the story is called "theStory" in the JSP and not "aStoryObjectInMyModel", the linkage between our model has been broken by the view, which is a good thing in this case
How do you do this?