EdgeCase
EdgeCase

Reputation: 4827

Spring MVC JSP - Include another JSP that has Dynamic Data

I have a Spring controller that calls a JSP (searchForm). I also need to have an included JSP from within the searchForm. However the included JSP is not static - its data comes from a database call. I know I can include a JSP within another JSP, similar to below, but how can I trigger a controller to populate the ArrayList that include.jsp displays?

Am I not going about this the correct way? The include.jsp will be used on more than one page, so I want to have it as an include.

<%@ include file="/WEB-INF/views/include.jsp" %>

Upvotes: 1

Views: 2116

Answers (1)

JB Nizet
JB Nizet

Reputation: 691715

I would simply call a method from the main controller, in order to populate the model with the data needed by the included JSP. And I would call this same method from every other controller dispatching to a page including the same JSP.

Upvotes: 2

Related Questions