0

On my web project I have a JSP page. In that JSP page there should be a DataGridView to show the data's from my database. Now how can I do this? How can I run servlet, process the data, pass it to JSP and then the data can be shown by using JSTL tags.

Please help me. Thanks in advance.

Maurice Perry
  • 9,261
  • 2
  • 12
  • 24
HjReyes
  • 41
  • 6

2 Answers2

0

First of all, you need to create a database and connect your application to it. Then, in your controller, (I'm assuming you are using an MVC framework) you should create an object of your database service util.

    List<Student> allDbEntries = StudentLocalServiceUtil.getStudents(0, 50);
0

I don't know what a DataGridView is, but in Java you would typically have a collection of objects defined as a request attribute, and you would write to the html output some fields of each object in the collection (one field per column):

<table>
  <thead>
    <tr>
      <th>Field 1</th>
      <th>Field 2</th>
      ...
    </tr>
  </thead>
  <tbody>
    <c:foreach var="row" items="${myCollection}">
    <tr>
      <td><c:out value="${row.field1}"/></td>
      <td><c:out value="${row.field2}"/></td>
      ...
    </tr>
    </c:foreach>
  </tbody>
</table>
Maurice Perry
  • 9,261
  • 2
  • 12
  • 24