This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Displaying Image from database on to the screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Displaying Image from database on to the screen" Watch "Displaying Image from database on to the screen" New topic
Author

Displaying Image from database on to the screen

ashok pandey
Greenhorn

Joined: Jun 26, 2001
Posts: 1
Dear,
Can any one solve my problem regarding displaying image on the screen.
I have stored my image in SQL database as data type called "image" format.
I am trying to get the binary data and display on the screen using jsp. It gives me the error
"java.lang.IllegalStateException"
Here is the code that i am using
CallableStatement stmtInsert= con.prepareCall( " { call spSM_Image }");
ResultSet rs = stmtInsert.executeQuery();

response.setContentType("image/jpeg");

if (rs.next())
{
byte [] buf = rs.getBytes("photo");
ServletOutputStream op = response.getOutputStream();

for(int i=0;i<Integer.parseInt(dim_image);i++)
{
op.write(buf[i]);
}
Pls. reply if some one can help this out

ashok pandey
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying Image from database on to the screen
 
Similar Threads
how to stop image being chached in browser in jsf
Image will not change on the Browser...Saving on the Tomcat Problem.....HELP...Please
Wrapping long text using h:outputText
How to show image in jsp from any where using browse button?
Relative path Issue