Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying an image from byte[] into JSP

 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi, I am using spring 3. I need your help in a isue.
I am trying to display an image which in MS-SQL db with datatype image. In the controller, I am retrieving as byteArray, but now question is how to display it.

Need your kind suggestions.

 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is more explannation:

image retrieval from sql server using java
our clients have a sql server database in which one of the table column of image data type holds a image.I am not able to retrieve the image.I have tried retrieving only certain no of bytes, but not able to see the image.If any body knows about this issue please reply thread
 
subhash kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make sure that it is fully uploaded image in the database not partially.
As you said you are able to get few byte, make sure that complete image is in database.
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NO, that image is uploaded fully because, I can see that image in VB application.it's migration project. hence, I am sure image is uploaded perfectly.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but not able to see the image.


EXACTLY how are you trying to display the image? Please show the code.

You do realize that a JSP is for characters and not binary data right?

Bill
 
subhash kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how you are retrieving the image from the database
can you post your code.
my following code is doing perfectly
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64975
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stop. Think.

A JSP is a template for creating an HTML page. So how does one display an image in an HTML page? Do you put the image data in the HTML page? Do you?

Stop. Think.
 
Sanjeev P Kulkarni
Greenhorn
Posts: 20
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also had the same problem but resolved by some help from google. Here is what I did: I created a servlet which will fetch the image from mysql database as below:



Then in my JSP page I called


This will display the image in a JSP page. Hope you find this as useful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic