• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image Retrieval and Display In JSP From Database

 
Mohnish Khiani
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please find the fault in the code...It is displaying a blank page on execution...I have stored the image in MS-Access





 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A number of problems:
1) There is Java code in your JSP. This has been considered bad practice for many years. The Java code should be in a Java class.
2) There is Java code in your JSP. This makes it hard to debug errors.
3) If the driver class is not found, you print an error and continue. But the database code will fail if the class is not found. You shouldn't continue on to execute the remaining code.
4) You don't close the resources in a finally block. Once the code works, you could have a resource leak.
5) The JSP outputs whitespace before the image. This will corrupt the image.

Did you check the logs for the actual exception you are getting? What did it say?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this article to find out why JSP is a phenomenally bad choice for doing this (beyond the fact that Java code in a JSP is abhorrent).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. If you want to display an image in a JSP, you use the <img> tag just like any other HTML page. The src should reference a servlet (not a JSP) that serves the image response.
 
Mohnish Khiani
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and what do i have to write in that servlet...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SearchFirst. It's been discussed many times.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic