This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Displaying Image from database on to the screen
 
Similar Threads
How to show image in jsp from any where using browse button?
Relative path Issue
Wrapping long text using h:outputText
how to stop image being chached in browser in jsf
Image will not change on the Browser...Saving on the Tomcat Problem.....HELP...Please