wood burning stoves 2.0*
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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