Home arrow static arrow Java Programming [Archive] - problem with file zipping!
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - problem with file zipping!
This topic has 19 replies on 2 pages.    « Previous | 1 | 2 |

Registered: 6/9/03
Re: problem with file zipping!  
Jul 19, 2004 2:29 PM (reply 15 of 19)

you have pointed out the correct problem. Yes, this file upload and downloading stuff is becoming really complicated. I have to upload any no.of files and again download another set of files from servlet. I am using just one single connection for this purpose.

I don't have much idea about how to simplify this issue...now that you have mentioned
do you have to send everything over one single network connection?

so is there a way where i can have multiple connections to do this job? if there is one. please give me some clue or link about how to do that...becoz i have been thinking that we can open just one stream per one connection between client and server. if you can help me with some intelligent solution. this would ease my headache.

Also for the file demarcation problem what i have done is, I have first sent an Hashmap object containing list of files to client/server and then send the actual file data using the objectOutputStream.write() method. this way i have correct data in correct files. but the problem is this is working for client_to_server communication. Now i am trying to do the same for server_to_client communication also. but it's not working.

Registered: 7/22/99
Re: problem with file zipping!  
Jul 19, 2004 11:21 PM (reply 16 of 19)

The server could for example open an extra port and tell the client to connect there, when it does the server dumps the file there (kind of like FTP passive mode). Or the client could do the same thing, open an extra port where the server would write the file (kind of like FTP active mode ... this has issues with firewalls and proxies though).

is working for client_to_server communication.

The problem is that it's unreliable: if you try different files or tweak some parameters like the buffer size you'll find that it's not working for client-to-server either. You need some reliable way, transmitting the file sizes would work.

Registered: 1/13/04
Re: problem with file zipping!  
Jul 20, 2004 6:18 AM (reply 17 of 19)

I've used the following approach to passing multiple files across a client/server network boundary:

1. Implement your own block transfer "channel". Your basic functions are open, write, and close. (You can also use open, read, close for moving data in the other direction.) I implemented this using RMI; the data transferred was simply a byte array.

2. Wrap this in your own RemoteInputStream and RemoteOutputStream.

3. Wrap this in ZipInputStream and ZipOutputStream.

Your main logic then consists of writing zip headers and data, or reading zip headers and data; you can depend on the zip streams recognizing each EOF and end of all files.

There are some design details for you to work out: Is this a synchronous this process, i.e., the server fetches/writes data when you ask it to, or you set up separate read/write threads on the server. (If you decide on the latter, then post a request, and I'll pass on some useful "pipes".

One caution: You will run into a little bit of tricky coordination at the end of the stream - at least you will when the data size gets very large. The reason is that the ZipOutputStream writes lots of trailer data after the last data block. ZipInputStream may recognize and signal an end-of-data before the ZipOutputStream (actually the lower-level block transfer) has processed those trailers.

Registered: 6/9/03
Re: problem with file zipping!  
Jul 20, 2004 8:02 AM (reply 18 of 19)

could you please send me your code so that i get clear idea of what you are telling!!

my application is a synchronous. the server has to send files to client only upon request.

according to what i undestand is the problem here is more towards a design issue rather than using RMI or streams or beans or anything else. simply changing my strategy only to find out i am in the same situation is very annoying. I am sure this file uploading and downloading is pretty common issue with the client/server applns. I agree that it's very tricky. what i am doing so far is:

(1) setup a objectoutputStream connection to the servlet
(2) upload files of different types
(3) at the server (servlet) end open an objectinputStream
(4) read all the files from the client (applet)
(5) execute a vc++ executable with spits the output files that need to be sent back to the client
(6) send the files back to the client ( i am having a problem at this point the rest all works perfectly fine for any size of files it still works fine)

well, any piece of code that shows this sort of communication (basically a two way communiction with file uploadin/downloading stuff) would be very helpful


Registered: 1/13/04
Re: problem with file zipping!  
Jul 20, 2004 12:26 PM (reply 19 of 19)

1. Sorry - code - except for "pipes" I mentioned - belongs to my employer, and I am not free to distribute it. But if you feel you want to go in the direction I used, I can try to talk you through it.

2. I take it on faith that your characterization of your problem is correct: That it's a design problem.

When you describe your design, I wonder

o What you are doing with an ObjectOutputStream? What kind of objects are you writing/reading?

o How did you implement "send files back to the client"? Is this a (servlet) ObjectOutputStream and (applet) ObjectInputStream?

o And the overall design: Do I take it that the client controls everything? That the client can decide when to write, and when to read?
This topic has 19 replies on 2 pages.    « Previous | 1 | 2 |