You might use <jsp:include>
with a <jsp:param>
.
<jsp:include page="yourFragment.jsp" >
<jsp:param name="formName" value="repCertificateEntityForm" />
</jsp:include>
See more details here.
Another option would be JSTL's <c:import>
tag with a <c:param>
(more flexible than JSP include):
<c:import url="yourFragment.jsp">
<c:param name="formName" value="repCertificateEntityForm" />
</c:import>
See more details here.
Alternatively, you can use JSP tag files.
<h:yourTag formName="repCertificateEntityForm" />
See more details here.
Note that my examples above were just that, examples, so I used repCertificateEntityForm
as the name of the form. In your code using <jsp:include>
, repCertificateEntityForm
is an object with properties on it, and you are trying to retrieve those properties. But the parameters can only be strings, so you most likely get an exception of:
javax.el.PropertyNotFoundException: Property 'controllerModel' not found on type java.lang.String
or something similar.
You are testing for a form type like ADD
, so you can change your code like this in your first JSP:
<jsp:include page="config.jsp">
<jsp:param name="formType" value="${repCertificateEntityForm.controllerModel.formType}" />
</jsp:include>
And then, in your config.jsp, you can test with:
<c:if test="${param.formType == 'ADD'}">
One other thing to be aware of is that the included JSP is included in the same context as the current JSP, so it has access to scope attributes, like the request attributes for example. If your repCertificateEntityForm
was added in scope with something like request.setAttribute("repCertificateEntityForm", form);
then the config.jsp can access it directly because it will be in scope. In that case you can change your first JSP to include just this:
<jsp:include page="config.jsp" />
And in your config.jsp you can retrieve the whole form object and keep your test like this:
<c:if test="${repCertificateEntityForm.controllerModel.formType == 'ADD'}">
Finally, I highly recommend you read some tutorials or documentation to get a better understanding of how things work in your application.