Click to See Complete Forum and Search --> : download a file from a popup window


digital_storm
05-10-2004, 03:22 PM
Hello,

I would be really glad if someone could help me with this little problem.

I have a site were visitors can download songs that I have made and I want to count how many times every song has been downloaded. I thought that I could do something like this...
I have a page with links to my songs. When a visitor clicks on a link they will be redirected to a page lets say bla.jsp?id=1
On bla.jsp I do a request.getParameter("id") and make a connection to a database were all my "songs" (the name of the songs) are stored with the same "id" as on the page.... Now I have solved the "count problem"

Now I want from bla.jsp open a new little window, above my bla.jsp, which will download current song. Lets say that my track is called "hello.mp3" with id=1. My songs are stored on my webbserver and not in a database in a catalogu called "musik" (musik/hello.mp3).

How do I do that?

Thanks in advance// D_S

Vladdy
05-10-2004, 04:01 PM
Just do a simple response redirect once you incremented your counter, why pollute screen with extra windows and depend on popup blockers. :confused:

digital_storm
05-10-2004, 04:36 PM
Hello,

Thanks for your answer Vladdy... you are right, you have to excuse my lack of knowledge but....
How do I redirect....will that create a new window in that frame which the link was clicked or will it just create a "downloadwindow" (that would be the best).

Thanks in advance!

Vladdy
05-10-2004, 04:43 PM
If the file is sent with MIME type that can not be displayed by browser, the Download/Execute window will show. If you check the "Download Evaluation Code" functionality on my site - that is what happening, when the user submits the form, the request is logged and then redirection is done.
I'm not sure how to do the redirection in jsp

digital_storm
05-10-2004, 04:59 PM
Hello Vladdy,

Ok, I dont have a clue if the file is sent with MIME, the mp3 file is on a webserver. There is no forms in this downloadprocess.

I thought that because that the jsp-page is created on the serverside and is send back to the client I could have a <body onload="viewWindow(id)> where id is my songindex.
Then in my vieWindow(id) I check index and create a new little downloadwindow that download correct song.

But I really dont know how to create that kind of window that downloads a file automaticly.

Thanks again.

Vladdy
05-10-2004, 05:09 PM
All files are send with MIME type, the question is what is it.
There does not have to be a form:

<a href="server.script?file=mySong.mp3">Download mySong.mp3</a>

server.script :
// Increment the counter
// redirect to GET['file']

I do not know jsp so I can not help you with implementation, but I do know this approach works just fine with ASP and PHP - it does not matter what server side language is - you are relying on HTTP protocol for redirection.

digital_storm
05-10-2004, 05:14 PM
Ok, I'll try it...

Thank you very much for you help!

Vladdy
05-10-2004, 05:16 PM
You are welcome.

fredmv
05-10-2004, 10:24 PM
Moved to the "other" section as this isn't JavaScript-related. As for sending HTTP headers, you might consider looking into the response.addHeader method.

freexbay
05-10-2004, 10:34 PM
sounds like a flash game theif to me.

Sam
05-10-2004, 10:50 PM
Originally posted by freexbay
sounds like a flash game theif to me.
what??