RE: file download servlet
Hi, Could you please check the link given below.It shows how to use Content-Disposition etc. http://www.esus.com/javaindex/j2ee/servlets/servletdlbinaryfile.html Regards Dinu -Original Message- From: Alexander Jesse [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 12, 2001 11:54 AM To: tomcat-user Subject: RE: file download servlet Hi, have you tried with different browsers? I remember vaguely that this kind of stuff can also be working in one browser and not work in another one... regards Alexander -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 11:53 PM To: [EMAIL PROTECTED] Subject: file download servlet I asked this question before, but I didn't get any reply. I post it again in hope someone could give me some hint. I have a file download servlet serves web browsers. request to file is like this http://192.168.1.105/download/servlet/download?filename=song.mp3 The file on the server side is song.mp3. But the file got download to browser is the servlet name instead. :( I heard i need to use the HTTP header res.setHeader(Content-Disposition,attachment; filename=\ + downloadFile + \;); Is Content-Disposition a standard header in HTTP spec? I heard i should use this whenever I don't want the content display on browser (force Save as Dialog box) Why everytime I download a file from the web server like song.mp3. there is no such HTTP header from web server? -- Content-Disposition I think web server is just like a download servlet. It sends raw bytes to web browser. After browser get the bytes, It will not konw what name the file should save as. Web server must send some kind of HTTP header to tell web browser what file name the file is saved as. right? How exactly is web server instruct web browser to pop up Save as Dialog box (on unknown mime type) and save the file with name = filename on server? Does web server use any special HTTP Header (like Content-Disposition) thanks. __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com
RE: file download servlet
But how exactly does web server instruct web browser to save the stream of bytes into a filename as filename on server? Does web server send any HTTP header like Content-Disposition to specify the file name to save? Since If i dont' set any HTTP headers in my servlet but just send the bytes. Browser will save the file as servlet name. thanks again --- Alexander Jesse [EMAIL PROTECTED] wrote: Hi, have you tried with different browsers? I remember vaguely that this kind of stuff can also be working in one browser and not work in another one... regards Alexander -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 11:53 PM To: [EMAIL PROTECTED] Subject: file download servlet I asked this question before, but I didn't get any reply. I post it again in hope someone could give me some hint. I have a file download servlet serves web browsers. request to file is like this http://192.168.1.105/download/servlet/download?filename=song.mp3 The file on the server side is song.mp3. But the file got download to browser is the servlet name instead. :( I heard i need to use the HTTP header res.setHeader(Content-Disposition,attachment; filename=\ + downloadFile + \;); Is Content-Disposition a standard header in HTTP spec? I heard i should use this whenever I don't want the content display on browser (force Save as Dialog box) Why everytime I download a file from the web server like song.mp3. there is no such HTTP header from web server? -- Content-Disposition I think web server is just like a download servlet. It sends raw bytes to web browser. After browser get the bytes, It will not konw what name the file should save as. Web server must send some kind of HTTP header to tell web browser what file name the file is saved as. right? How exactly is web server instruct web browser to pop up Save as Dialog box (on unknown mime type) and save the file with name = filename on server? Does web server use any special HTTP Header (like Content-Disposition) thanks. __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com
RE: file download servlet
The server sends a header that describes the file type. See mime types. At 10:45 AM 9/12/2001, you wrote: But how exactly does web server instruct web browser to save the stream of bytes into a filename as filename on server? Does web server send any HTTP header like Content-Disposition to specify the file name to save? Since If i dont' set any HTTP headers in my servlet but just send the bytes. Browser will save the file as servlet name. thanks again --- Alexander Jesse [EMAIL PROTECTED] wrote: Hi, have you tried with different browsers? I remember vaguely that this kind of stuff can also be working in one browser and not work in another one... regards Alexander -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 11:53 PM To: [EMAIL PROTECTED] Subject: file download servlet I asked this question before, but I didn't get any reply. I post it again in hope someone could give me some hint. I have a file download servlet serves web browsers. request to file is like this http://192.168.1.105/download/servlet/download?filename=song.mp3 The file on the server side is song.mp3. But the file got download to browser is the servlet name instead. :( I heard i need to use the HTTP header res.setHeader(Content-Disposition,attachment; filename=\ + downloadFile + \;); Is Content-Disposition a standard header in HTTP spec? I heard i should use this whenever I don't want the content display on browser (force Save as Dialog box) Why everytime I download a file from the web server like song.mp3. there is no such HTTP header from web server? -- Content-Disposition I think web server is just like a download servlet. It sends raw bytes to web browser. After browser get the bytes, It will not konw what name the file should save as. Web server must send some kind of HTTP header to tell web browser what file name the file is saved as. right? How exactly is web server instruct web browser to pop up Save as Dialog box (on unknown mime type) and save the file with name = filename on server? Does web server use any special HTTP Header (like Content-Disposition) thanks. __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com
RE: file download servlet
In your servlet's doGet processing, you will need to have a line of code like: resp.setContentType(text/plain); Of course, for your mp3 file, it won't be text/plain, but a different mime-type (audio/mpeg or whatever) - Tony -Original Message- From: Tim O'Neil [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 12, 2001 2:04 PM To: [EMAIL PROTECTED] Subject: RE: file download servlet The server sends a header that describes the file type. See mime types. At 10:45 AM 9/12/2001, you wrote: But how exactly does web server instruct web browser to save the stream of bytes into a filename as filename on server? Does web server send any HTTP header like Content-Disposition to specify the file name to save? Since If i dont' set any HTTP headers in my servlet but just send the bytes. Browser will save the file as servlet name. thanks again --- Alexander Jesse [EMAIL PROTECTED] wrote: Hi, have you tried with different browsers? I remember vaguely that this kind of stuff can also be working in one browser and not work in another one... regards Alexander -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 11:53 PM To: [EMAIL PROTECTED] Subject: file download servlet I asked this question before, but I didn't get any reply. I post it again in hope someone could give me some hint. I have a file download servlet serves web browsers. request to file is like this http://192.168.1.105/download/servlet/download?filename=song.mp3 The file on the server side is song.mp3. But the file got download to browser is the servlet name instead. :( I heard i need to use the HTTP header res.setHeader(Content-Disposition,attachment; filename=\ + downloadFile + \;); Is Content-Disposition a standard header in HTTP spec? I heard i should use this whenever I don't want the content display on browser (force Save as Dialog box) Why everytime I download a file from the web server like song.mp3. there is no such HTTP header from web server? -- Content-Disposition I think web server is just like a download servlet. It sends raw bytes to web browser. After browser get the bytes, It will not konw what name the file should save as. Web server must send some kind of HTTP header to tell web browser what file name the file is saved as. right? How exactly is web server instruct web browser to pop up Save as Dialog box (on unknown mime type) and save the file with name = filename on server? Does web server use any special HTTP Header (like Content-Disposition) thanks. __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com
Re: file download servlet
Hi, To download file with the specific file name like song.mp3 as your following url http://192.168.1.105/download/servlet/download?filename=song.mp3 changed it with following url- http://192.168.1.105/download/servlet/download/song.mp3?filename=song.mp3 . So while downloading the extrapath song.mp3 will be the filename. -Ketan chiuming wrote: I asked this question before, but I didn't get any reply. I post it again in hope someone could give me some hint. I have a file download servlet serves web browsers. request to file is like this http://192.168.1.105/download/servlet/download?filename=song.mp3 The file on the server side is song.mp3. But the file got download to browser is the servlet name instead. :( I heard i need to use the HTTP header res.setHeader(Content-Disposition,attachment; filename=\ + downloadFile + \;); Is Content-Disposition a standard header in HTTP spec? I heard i should use this whenever I don't want the content display on browser (force Save as Dialog box) Why everytime I download a file from the web server like song.mp3. there is no such HTTP header from web server? -- Content-Disposition I think web server is just like a download servlet. It sends raw bytes to web browser. After browser get the bytes, It will not konw what name the file should save as. Web server must send some kind of HTTP header to tell web browser what file name the file is saved as. right? How exactly is web server instruct web browser to pop up Save as Dialog box (on unknown mime type) and save the file with name = filename on server? Does web server use any special HTTP Header (like Content-Disposition) thanks. __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
Re: file download servlet
you could go a step further than that, and remove the query string altogether, extracting it from the request url. That way the end user wouldn't even know it was being served by a servlet (well, the /servlet might give it away, but you could change that if it mattered)... cheers dim On Thu, 13 Sep 2001, Ketan Patel wrote: Hi, To download file with the specific file name like song.mp3 as your following url http://192.168.1.105/download/servlet/download?filename=song.mp3 changed it with following url- http://192.168.1.105/download/servlet/download/song.mp3?filename=song.mp3 . So while downloading the extrapath song.mp3 will be the filename. -Ketan chiuming wrote: I asked this question before, but I didn't get any reply. I post it again in hope someone could give me some hint. I have a file download servlet serves web browsers. request to file is like this http://192.168.1.105/download/servlet/download?filename=song.mp3 The file on the server side is song.mp3. But the file got download to browser is the servlet name instead. :( I heard i need to use the HTTP header res.setHeader(Content-Disposition,attachment; filename=\ + downloadFile + \;); Is Content-Disposition a standard header in HTTP spec? I heard i should use this whenever I don't want the content display on browser (force Save as Dialog box) Why everytime I download a file from the web server like song.mp3. there is no such HTTP header from web server? -- Content-Disposition I think web server is just like a download servlet. It sends raw bytes to web browser. After browser get the bytes, It will not konw what name the file should save as. Web server must send some kind of HTTP header to tell web browser what file name the file is saved as. right? How exactly is web server instruct web browser to pop up Save as Dialog box (on unknown mime type) and save the file with name = filename on server? Does web server use any special HTTP Header (like Content-Disposition) thanks. __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
Re: file download servlet
I was using the path in a similar way but passing the whole URL: e.g. http://192.168.1.105/test1/servlet/test1/http://www.example.com/main/page1.html This worked fine for tomcat v3.2.1 but when I upgraded to v3.2.3 the '//' got converted to '/'. I realise this was for security reasons but, out of interest, is the above URL really considered illegal or a security threat? - Original Message - From: Dmitri Colebatch [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, September 13, 2001 1:48 PM Subject: Re: file download servlet you could go a step further than that, and remove the query string altogether, extracting it from the request url. That way the end user wouldn't even know it was being served by a servlet (well, the /servlet might give it away, but you could change that if it mattered)... cheers dim On Thu, 13 Sep 2001, Ketan Patel wrote: Hi, To download file with the specific file name like song.mp3 as your following url http://192.168.1.105/download/servlet/download?filename=song.mp3 changed it with following url- http://192.168.1.105/download/servlet/download/song.mp3?filename=song.mp3 . So while downloading the extrapath song.mp3 will be the filename. -Ketan chiuming wrote: I asked this question before, but I didn't get any reply. I post it again in hope someone could give me some hint. I have a file download servlet serves web browsers. request to file is like this http://192.168.1.105/download/servlet/download?filename=song.mp3 The file on the server side is song.mp3. But the file got download to browser is the servlet name instead. :( I heard i need to use the HTTP header res.setHeader(Content-Disposition,attachment; filename=\ + downloadFile + \;); Is Content-Disposition a standard header in HTTP spec? I heard i should use this whenever I don't want the content display on browser (force Save as Dialog box) Why everytime I download a file from the web server like song.mp3. there is no such HTTP header from web server? -- Content-Disposition I think web server is just like a download servlet. It sends raw bytes to web browser. After browser get the bytes, It will not konw what name the file should save as. Web server must send some kind of HTTP header to tell web browser what file name the file is saved as. right? How exactly is web server instruct web browser to pop up Save as Dialog box (on unknown mime type) and save the file with name = filename on server? Does web server use any special HTTP Header (like Content-Disposition) thanks. __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
RE: file download servlet
Hi, have you tried with different browsers? I remember vaguely that this kind of stuff can also be working in one browser and not work in another one... regards Alexander -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 11, 2001 11:53 PM To: [EMAIL PROTECTED] Subject: file download servlet I asked this question before, but I didn't get any reply. I post it again in hope someone could give me some hint. I have a file download servlet serves web browsers. request to file is like this http://192.168.1.105/download/servlet/download?filename=song.mp3 The file on the server side is song.mp3. But the file got download to browser is the servlet name instead. :( I heard i need to use the HTTP header res.setHeader(Content-Disposition,attachment; filename=\ + downloadFile + \;); Is Content-Disposition a standard header in HTTP spec? I heard i should use this whenever I don't want the content display on browser (force Save as Dialog box) Why everytime I download a file from the web server like song.mp3. there is no such HTTP header from web server? -- Content-Disposition I think web server is just like a download servlet. It sends raw bytes to web browser. After browser get the bytes, It will not konw what name the file should save as. Web server must send some kind of HTTP header to tell web browser what file name the file is saved as. right? How exactly is web server instruct web browser to pop up Save as Dialog box (on unknown mime type) and save the file with name = filename on server? Does web server use any special HTTP Header (like Content-Disposition) thanks. __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com