Implementation of the JSP template (composite view template)

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

My idea was to take one jsp and include multiple pages, for example:

<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 accessible to the user. How can I deny access to all .jsp files, with the exception of one template.

After that, I need a filter or servlet to insert the paths into the Values ​​object.

Update I do not mean that WEB-INF is accessible from the file system (or the Web server), but from the web application through the controller with the current layout layout.getcontent()to the URL / user input.

What are the common frameworks used to handle the Composite View template?

+3
3

Pro Java EE Spring , Composite View:

Tiles , Struts Spring. SiteMesh Decorator. - Tiles .

+3

, WEB-INF, . JSP WEB-INF/jsp, ( JSP) .

+4

Source: https://habr.com/ru/post/1725295/


All Articles