Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Keeping Images for a Employee Object

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers ,

I am making a Emplyoyee Object with all their variables like Age , EmpId , Name ,sal so for this i produced getters and setters of each variable.

I also want to keep a Image/photo of the Employee . what is the way to proceed?

Do i need to produce setters and getters of Blob tpye ? If so what is the datatype i need to put on to the Employee Object for this ?

If this is not the efficient way , can anybody please tell me whats the way to do this ?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use InputStream.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya i will be doing this at the time of retreival

Blob b = rs.getBlob(2);

InputStream iis = b.getInputStream();

But what about setter and getters on to the Employee Object and the datatype there to be used ??

I think you got my question .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of what use would it be? How does one show an image in an HTML page? With a Blob? No, with an <img> tag to a separate resource.

So with that in mind, how would you proceed?
 
Alok Kushwah
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Employee class Images should be declared as




You can save byte array as blob in database and retrieve the data in back in array.

But to serve image to browser, you cannot use this VO|DTO directly, you have to create a new servlet to server binary image data. Use URL of servlet in <img> tag.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Alok ,

Bear thanks for your concern ,i am trying to proceed in this way :

i will be pointing out to File which is written with the help of the InputStream from the Blob .with the help of the Image tag from the JSP. what do you think is this the way to go ??
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't necessarily have to write to a file. Whatever URl the <img> tag references can be a servlet that streams the image data.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!