I have been trying this for a while with no luck. I want to know if there is a way to include response of a server request (i.e. a Spring controller) inside a JSP.
I am trying to build an independent module which will rely on some specific objects and will print the HTML based on these objects. So I want to create a Controller method which will take care of dependencies and return this JSP as response. I can then include a call in the parent JSP so that it hits the controller method and injects the response returned by this method in the parent JSP.
I read somewhere that jsp:include can be used for this purpose as follows:
<jsp:include page="/test-url" flush="true"/>
Where /test-url will map to a Spring controller method.
But when I run this, i get the following exception:
Servlet.service() for servlet dispatcher threw exception: java.lang.IllegalStateException: Cannot forward after response has been committed
Please provide your valuable inputs if you have some idea about this?