• Post Reply Bookmark Topic Watch Topic
  • New Topic

Streams and EJB

 
Hari babu
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have some pdf data stored in my database which will be of bytes. I want to read that database data and send it to the servlet to display the pdf. Is it feasible enough to use the streams in EJB. I read that we should not be using the File streams in my EJB layer
For e.g in my implementation bean can i have this :
public DataInput getPdf(){
// knows how to query for the pdf and send it to the calling servlet
}
Hari
 
Manish Kamat
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if your client and ejb are situated on different machines(multitier environment) streams can't be sent over the network as they are not serialized.in this case you need to convert streams into serialized objects e.g. String etc.which can be easily sent over the network.when you receive this string in your ejb again you need to convert this into bytes and then store it in the database.
while fetching this field do exactly reverse of above procedure.
i've successfully done exactly same...hope this information will help you.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!