This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Signed applet download

 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. As this is my first time doing applet. Please be patient with me.

I'm in the process of building a JSP project that allows a JAR file to be downloaded from server to client. Inside this applet, it will state the path on where to download the file to.

I hope this doesn't sound too much..

Does anyone have some kind of example of this applet which i can learn from? The examples that I've found does not allow me to looked into their contents.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What features does an applet add to the download process that a simple HTML link wouldn't?
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf. I was told that I'll need to use a signed applet in order to access the client file system.

In this case, I'll need the downloaded file to be placed in another folder without the user choosing the place to download to.

I've tried looking for applet file download. I've managed to find some which is trial programs but I'm not able to modify them.
[ October 01, 2007: Message edited by: Adrian Lee ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, OK. Downloading the contents of a file isn't hard. The following code provides you with an InputStream, the contents of which you can save to the local file.


Signing an applet is discussed in HowCanAnAppletReadFilesOnTheLocalFileSystem
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf for your help.
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again guys. Sorry, I don't quite understand on how I'm able to do this.

And there's some things I'll need to clarify.

Since the JAR file which is supposed to be downloaded to the client system is stored in eg. (d:/download).

1) Does it mean that I need to make the file into DataOutputStream?
2) Is it similiar to socket programming which I'll need to open a socket in order for the file download to start?

Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1) Does it mean that I need to make the file into DataOutputStream?

A FileOutputStream is called for here.

2) Is it similiar to socket programming which I'll need to open a socket in order for the file download to start?

No. Those two lines I posted earlier accomplish the download. You need to add code that reads bytes from the InputStream and writes them to the FileOutputStream (which is hooked up to a File).

Here's some code which copies data from in InputStream to an OutputStream that you can adapt.
[ October 02, 2007: Message edited by: Ulf Dittmer ]
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf, Thanks for being very helpful!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic