Solved

How to send a File, bundled in ValueObject, from Swing Client to EJB?

Posted on 2004-08-06
30
165 Views
Last Modified: 2013-11-24
Hi Folks,

One suggestion/help reqrd .
My friend has a client/server architecture . Client is in Swings running in
windows and server is in EJB running in Unix .
He is making a session bean call from client to server .
Problem is he needs to send a file to server from client .
 With the existing architecture he is sending all the information from clinet to
server after filling up a value object . (for Ex value object contains all
the attributes to be sent to server.).
Now he needs to send a file to server after bundling it into Value Object .
He tried sending a File object that does not work .
What is the way he sends a File to Server bundled in the ValueObject? Or should he follow some other method?
0
Comment
Question by:Shweta
  • 7
  • 7
  • 6
  • +3
30 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
Comment Utility
You could send a file as a byte[]
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Another way is to use a MDB send the file in pieces and then reassemble it
0
 

Author Comment

by:Shweta
Comment Utility
Hi CEHJ,

 In current architecture it's a Swing Client, sending the file to a Session EJB. The file will be of huge size as it contains millions of records in it... It's a good idea to divide the file and send.. but is it not difficult to use this approach with ValueObject? I mean how to send a file chunk object in Value Object ?

Thanks,
Shweta
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>I mean how to send a file chunk object in Value Object ?

This would simply be a wrapper of byte[]. You may need a chunk number as well
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
How do you currently send the vo?
0
 

Expert Comment

by:raghava_dg
Comment Utility
hi , if you send files as byte[] then there is a prob. byte[] can hold max of Integer.MAX_VALUE so if the file is large then we can not store it in a single byte[] .
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>if the file is large then we can not store it in a single byte[] .

Naturally i'm not suggesting sending the whole file in one array ;-)
0
 

Author Comment

by:Shweta
Comment Utility
currently we are bundling all the infos to respective attributes and sending it to server by a session bean call. so if i add another attribute for file content in my VO and if i want to split it it is a problem. since my VO will be one nd my file contentattibute is inside my VO.
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
As already suggested add a byte[] instance variable and asign the bytes there. Then send the vo with the byte[] variable. Repeat more times if the byte array can't hold all the info of your value object. YOu will just need a few more trips to the server and back.
0
 

Author Comment

by:Shweta
Comment Utility
ya, may be that is what I have to do . any other suggetions welcome.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Try to arrange things so that you're calling a method on your EJB that only sends the file bytes
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
You could always open a SocketChannel or a Socket and send the whole file (without wrapping it up in a vo) byte by byte or in a buffer. But this will require additional code in both the server and client side.
0
 

Author Comment

by:Shweta
Comment Utility
yes i may have consider that option of sending byte[] in a batches. in this case one more thing i need to makesure is that i receive all the packets.. anyways i will consider this approach . all of you thanks for helping.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 35

Expert Comment

by:girionis
Comment Utility
Please let us know how you are getting on :)
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>in this case one more thing i need to makesure is that i receive all the packets.. anyways i will consider this approach

That's why i suggested sending a packet number as well earlier:

>>You may need a chunk number as well
0
 

Author Comment

by:Shweta
Comment Utility
ok .  will try that
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
you don't actually need a packet number, all the blocks will get delivered. You just need to include an indicator into your protocol to indicate the last block.
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
This is a multiple account problem, I guess - Shweta, raghava_dg.

http://www.experts-exchange.com/Programming/Programming_Languages/Q_21083663.html

Shweta/ Raghava - whatever your name is - this is illegal as per the member agreement. Pls post back clarifying on this page if you're using two accounts or not, or I will tell the moderators.
0
 

Author Comment

by:Shweta
Comment Utility
nop , my frnd asked this qtn to me . so i posted this qtn here . if u think logically there is no point in posting the same qtn to the group with 2 id's . coz the solutions given by the members will be same for both qtn .
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
I definitely see a logical point there - that is to use the points from both accounts - that is what some people do when they run out of question-points. The question which you've posted is exactly the same as the one posted by Raghava - word to word.
0
 

Author Comment

by:Shweta
Comment Utility
did u noticed one more logical point? . if a person is using 2 accounts and if he posts same qtn frm 2 accounts he end up giving points in both accounts for same qtn. :)
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
Well, if you had understood what I meant - he gives points from 2 accounts, not from one. And that is not a loss. Anyway, I guess anyway will contact you.
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>> anyway will contact you

*someone will contact you.
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
That would not work because:

>> The file will be of huge size as it contains millions of records in it...

Accept his third comment:

"This would simply be a wrapper of byte[]. You may need a chunk number as well"
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
Ooh. The third comment was better.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Not really, a chunk number is unnecesary
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
Yeah, but the chunk number thing is just an idea in that comment as he uses 'you "may"'. Also:

>> This would simply be a wrapper of byte[]

Another one also says:

>> Naturally i'm not suggesting sending the whole file in one array ;-)

The first comment which was accepted definitely does not suit the situation because a mere byte[] array is not enough for this case, as mentioned by the asker ;-) so I thought accepting the other comment would be better.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now