Forums Register Login

Servlet not populating html table on jsp page

+Pie Number of slices to send: Send
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


+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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?
He baked a muffin that stole my car! And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2456 times.
Similar Threads
Unable to connect to database
Can i put a table inside tbody of another table?
Export to excel
best option for implementing form
how to position div over table
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 23:13:11.