• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileWriter and Stream error

 
Rod Bailey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to stream or write a file from a server to client PC?

I get the following error:
java.io.FileNotFoundException: C:\download\download.txt(The system cannot find the path specified)
I'm not sure if a server can write to or stream to a specific directory on the client side.
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this being called in a servlet, or some supporting back end classes? Since the call is being made by something on a server, then it's going to be looking for a filepath on the server, not the client side.
Could you maybe explain what it is you are trying to do in the application? That may help us to provide you with some pointers.
 
Rod Bailey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what I am needing to do:
Have a database contain word documents. I'll use jsps and java to view the content of this database. A user will select up to 25 documents to transfer to their PC (client). I've been asked to compress these files just before the transfer then decompress them after the transfer. Once the user is finished modifying the files they will get another jsp to upload the documents back. Again, compress and decompress. I'm trying to perform this without an applet running on the client side. Assuming the applet will handle the compression from and to the server. I'm investigating if I can compress the file on the server first, use an output stream to write it to the client side then decompress it.

Any suggestions?
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that the JSPs are also all server-side. Sure they come up as a page in the clients browser, but it is still being handled by the server. There is no client code, and there is no connection that you can open a stream with.
Even with using an applet, you would have to somehow send a new security policy to each client, since normally applets are not allowed access to the local file system, for good reason.
I don't think you could even FTP the files, unless every client has an FTP server running.
Without actually having a client-side application, I'm not sure of the way you could do this (if it is even possible).
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some browsers support uncompress-on-the-fly; if this is for an Intranet application, you might check with your IT folks if your desktops can do this. But as far as compressing the upstream part: you're not going to be able to do this without putting some code on the desktop. An applet is a possibility, although as Jason said, there are security issues. Another possibility is to use JavaWebStart, which I believe is pre-configured to allow some limited disk access.
 
Rod Bailey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like my only option is to use an applet on the client side to decompress and compress. But my only concern is: What will initialize or execute the applet? On previous programs I use applet tags on my jsps to initialize the applet. Can an applet execute when a file hits the directory? I guess this would be like a daemon.
Rod
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic