File Download

K

Krish

I am new to JSP and here stuck with a problem.....need help

Can anyone tell me how can i provide a download option in JSP for users
for a file which can be in any directories.......


please help
 
S

Simon Brooke

Krish said:
I am new to JSP and here stuck with a problem.....need help

Can anyone tell me how can i provide a download option in JSP for users
for a file which can be in any directories.......

Just link to the file, as you would in HTTP. There's nothing special or
clever you need do.

--
(e-mail address removed) (Simon Brooke) http://www.jasmine.org.uk/~simon/
;; Sending your money to someone just because they've erected
;; a barrier of obscurity and secrets around the tools you
;; need to use your data does not help the economy or spur
;; innovation. - Waffle Iron Slashdot, June 16th, 2002
 
O

Oliver Wong

Simon Brooke said:
Just link to the file, as you would in HTTP. There's nothing special or
clever you need do.

This will only work if the file is in a directory which is being served
by the webserver. E.g. if you want to provide download to a file like
"C:\myFile.zip", you'll probably instead need to provide a link to a page
whose sole task is to read arbitrary files on the file system, and remit
their contents, e.g. <a
href="./downloader.jsp?link=C:\myFile.zip">Download</a>. But then you'd
probably want to implement some security so that people couldn't use that
page to download, for example, a list of username and passwords from your
server.

- Oliver
 
K

Krish

thanks for the solution......but what should I code in
downloader.jsp...
Thanks oncce again
 
S

Simon Brooke

Oliver Wong said:
This will only work if the file is in a directory which is being
served
by the webserver. E.g. if you want to provide download to a file like
"C:\myFile.zip", you'll probably instead need to provide a link to a page
whose sole task is to read arbitrary files on the file system, and remit
their contents,

Do NOT - not ever - do that. Your webserver has a lot of security built in
precisely to prevent attackers being able to read arbitrary files in your
file system. If potential attackers /can/ read arbitrary files in your
file system, you just lost control of your server.

If you want people to be able to download a file, move that file into the
webserver's document root. Do NOT try to work around that.
 
O

Oliver Wong

Krish said:
thanks for the solution......but what should I code in
downloader.jsp...
Thanks oncce again

Sorry, I don't know. I'm more of a PHP guy than a JSP guy.

- Oliver
 
A

Andrew Thompson

Krish said:
thanks for the solution......but what should I code in
downloader.jsp...

Java, primarily.

As an aside - this is not a 'code generating machine'.
If you don't know what to put in the JSP (after
getting broad directions from those experienced in
server security), you either need ot learn Java or
hire a Java programmer.

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,244
Latest member
cryptotaxsoftware12

Latest Threads

Top