I have an ArrayList in my Servlet code. Now, I want to show that ArrayList in a tabular format. How can I achive this?
E.g.
ArrayList dataList = new ArrayList();
// dataList Add Item
out.println("
" + dataList +"
"); // I want to view it in tabular format.解决方案
Tables are in HTML to be represented by
In the servlet, put the list in the request scope and forward to a JSP:
request.setAttribute("dataList", dataList);
request.getRequestDispatcher("/WEB-INF/dataList.jsp").forward(request, response);
In the /WEB-INF/dataList.jsp, you can present it in a HTML
...
${dataItem.someProperty} | ${dataItem.otherProperty} |
See also: