I have a HomePage.jsp which has another jsp, Reporting.jsp included in it using,
<%@ include ...%>
I would want to make this page load data from the servlet whenever a specific link is clicked on HomePage.jsp.
I tried using jQuery AJAX method in order to POST to servlet, however, the problem now is how can I passed the data to my included jsp?
The included JSP is using JSTL to read data from the request and render the jsp accordingly. (I understand there are other ways such as returning JSON / XML file servlet and then use javascript or jquery to parse it, but is there any way to handle it for the JSTL's way)
On the HomePage.jsp, my AJAX function looks like this
$("#ReportingLink_id").on("click", function(){
$.ajax({
type: "POST",
url: "MaintainUser",
data: "",
success: function(result){
},
error: function(){
}
})
On the Reporting.jsp, my JSTL looks something like this
<tbody>
<c:forEach var="tempProject" items="${projectInfo}">
<tr>
<td><span class="ClickableID"><u><c:out value="${tempProject.getProjectID()}"></c:out></u></span></td>
<td><c:out value="${tempProject.getProjectName()}"></c:out></td>
<td><c:out value="${tempProject.getClientName()}"></c:out></td>
<td><c:out value="${tempProject.getAssignedProjectGroupName()}"></c:out></td>
<td><c:out value="${tempProject.getQuotedDuration()}"></c:out></td>
<td><c:out value="${tempProject.getForecastBudget()}"></c:out></td>
</tr>
</c:forEach>
</tbody>
On my servlet, I tried this,
request.setAttribute("projectInfo", projectInfo);
rd = request.getRequestDispatcher("/JSPs/SubJSPs/ProjectReporting.jsp");
rd.forward(request, response);
I can confirm that the servlet has received the POST request from the AJAX event but somehow nothing is shown on the Reporting.jsp after the request has been forwarded.