I have a servlet that returns a collection of model bean objects to a jsp page. From there I want to display that data, but I'm not sure of the correct way to do it.
The average number of rows returned from the database will probably be less than a few hundred at best.
I'm using Java 1.6 and the default jQuery with Datatables 1.10.4.
I did verify that the data is in the collection and that it goes out in the request to the JSP page.
Originally, I had hard coded values for the data to make sure I had the datatable setup properly, based on Javascript Sourced Data from the Datatables site, but now I have actual data and I'm not sure how to get it in the table properly.
Here is my new jQuery code that is showing this error here in Eclipse:
"ajax': './MyServlet", //invalid property assignment error?
I'm not sure what that error means?
<!-- jQuery code -->
$(document).ready(function () {
$('#datatable').dataTable({
"processing": true,
"ajax': './MyServlet",
"columns": [
{ "data": "Last Name" },
{ "data": "First Name" },
{ "data": "Mailing Address" },
...
]
});
});
Here is my HTML datatable code with scriptlets, for now to loop through my collection of objects and add in columns/rows. I saw this in another example, so I used it just trying to get it working.
<!-- The datatable in the jsp page -->
<table width="100%" id="datatable" class="display compact" cellspacing="0">
<%
if(null != modelBeanCollection && modelBeanCollection.size() > 0) {
%>
<%
List<modelBean> projectList = (List<modelBean>)(List<?>) modelBeanCollection;
for (modelBean project : projectList) {
%>
<tr>
<td><%=project.getLastName()%></td>
<td><%=project.getFirstName()%></td>
<td><%=project.getAddress1()%></td>
...
</tr>
<%}
}%>
</table>
My main question is, what is the best practice to display an array of objects in a jsp page, with what I have, using datatables, based on a few hundred rows of data?
"ajax': './MyServlet"you have single quotes in here