• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet not populating html table on jsp page

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic