views:

175

answers:

1

What is the best way to implement the Composite View Pattern for a Java website?

My idea was to take one jsp and include multiple pages like:

<h1>Layout Start</h1>
<%
Values values = DataHandler.getValues(request);
LayoutHelper layout = values.getLayout();
out.println("Layout.getContent(): " + layout.getContent());
%>

<jsp:include page="<%= layout.getContent() %>" flush="false" />

<h1>Layout End</h1>

But then all my small jsp files in the WEB-INF directory are still avalible to the user. How can i denine access to all jsp files but one for the template. And then I need a filter or Servlet to inserter the pathes in the Values object.

+1  A: 

Any file that's in WEB-INF is not directly accessible by the user. I typically put all my JSPs in WEB-INF/jsp, and then only the controller servlet (or other JSP pages) can access them.

Kaleb Brasee
What he said. This is in fact what a lot of framework do/encourage.
Chris Harcourt