Is there any way to display an image inside a table on JSP based on a mySQL database id?

This is my current SQL database

| Field      | Type        | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| product_id | int         | YES  |     | NULL    |       |
| category   | varchar(30) | YES  |     | NULL    |       |
| name       | varchar(30) | YES  |     | NULL    |       |
| qty        | int         | YES  |     | NULL    |       |
| price      | float       | YES  |     | NULL    |       |
+------------+-------------+------+-----+---------+-------+ 

Is there anyway I can add an Image field with blob type (or any other alternative) and display it in a table according to its product_id using JSP?

My JSP code for the current table I have is as follows

out.println("<table style='margin-left: auto; margin-right: auto;'><tr>");

         out.println("<th></th>");
         out.println("<th> CATEGORY </th>");
         out.println("<th> NAME </th>");
         out.println("<th> PRICE </th>");

         out.println("</tr>");
         while(rset.next()) {
            out.println("<tr><td><input type='checkbox' name='product_id' value="
                  + "'" + rset.getString("product_id") + "' /td>"
                  + "<td>" + rset.getString("category") + "</td><td>"
                  + rset.getString("name") + "</td><td> $"
                  + rset.getString("price") + "</td></tr>");
         }
         out.println("</table>");


Read more here: https://stackoverflow.com/questions/66336753/is-there-any-way-to-display-an-image-inside-a-table-on-jsp-based-on-a-mysql-data

Content Attribution

This content was originally published by ztw at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: