• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet not populating html table on jsp page

 
Ayo Babatope
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,

I am trying to populate an html table on a jsp page with a servlet that queried a database but it is not populating the table..

Kindly help out..

Servlet Code: Viewall.java


jsp code: home.jsp


 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that the code is legible we find this suspicious spot:



Inside ther loop you always set the same attribute which is however derived from the ResultSet.
Not unconceivable, but still suspicious.
We do not know what Result is and what ResultSupport.toResult does.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for the moment we'll ignore the fact that all your database access and data manipulation should be in a DAO and not in the servlet. But the immediate problem here is trying to pass the result set to the jsp page. The result set needs to be processed into a collection of some sort and that collection will be set as a request attribute. The jsp doesn't know what to do with a ResultSet object.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He's not passing the resultset to the JSP, he's processing it using a JSTL package class (used to support the SQL JSTL tags) to create a Result, which I presume is JSTL-compatible.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:He's not passing the resultset to the JSP, he's processing it using a JSTL package class (used to support the SQL JSTL tags) to create a Result, which I presume is JSTL-compatible.


Ah, well that something different. I saw "request.setAttribute("result", result);" and made a bad assumption. I see Ivan picked up on the ResultSupport.toResult() thing. Now I'm curious to see what that is actually doing.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ResultSupport and Result classes are defined by the JSTL to support the sql tags. I'd never use the sql tags in a page, and I've also never used the Result classes.

I either do all my jDBC deep in the model, or let an ORM package do it for me, so a resultset never gets this close to the UI.

To the OP: what have you done to debug this issue?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!