aspose file tools*
The moose likes JSP and the fly likes Displaying an image from byte[] into JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Displaying an image from byte[] into JSP" Watch "Displaying an image from byte[] into JSP" New topic
Author

Displaying an image from byte[] into JSP

Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205

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

Joined: Oct 01, 2008
Posts: 205
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

Joined: Jul 14, 2010
Posts: 63
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.


Subhash Kumar
Attitude is everything
Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
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

Joined: Mar 22, 2000
Posts: 12781
    
    5
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

Joined: Jul 14, 2010
Posts: 63
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

Joined: Jan 10, 2002
Posts: 61201
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sanjeev P Kulkarni
Greenhorn

Joined: Nov 08, 2009
Posts: 20

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.


Sanjeev
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying an image from byte[] into JSP