Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSP file download

Reply
Thread Tools

JSP file download

 
 
Kasper M. Nowak
Guest
Posts: n/a
 
      07-22-2003
Hello,

I need to know how to do the following:
User logs in, password is compared with database, then user can see a
list of files in "his" directory (which only he can have access to) and
download them. For every user there is a separate directory with
different files.
Login and all the rest ist done with JSP and working, my problem is I
just don'T have any idea how to solve the problem with the
directories/files and downloading them. I would really appreciate any
help like code samples, links, .. whatever

Thanks a lot in advance

Kasper M. Nowak

 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      07-22-2003
Kasper M. Nowak wrote:
> I need to know how to do the following:
> User logs in, password is compared with database, then user can see a
> list of files in "his" directory (which only he can have access to) and
> download them. For every user there is a separate directory with
> different files.
> Login and all the rest ist done with JSP and working, my problem is I
> just don'T have any idea how to solve the problem with the
> directories/files and downloading them. I would really appreciate any
> help like code samples, links, .. whatever


Are you already using a database? Do you have a record for each user
account in the database? Or do you prefer to use filesystem storage?
You'll need to be more specific about your design.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
 
Kasper M. Nowak
Guest
Posts: n/a
 
      07-22-2003
Chris Smith wrote:

> Kasper M. Nowak wrote:
>
>>I need to know how to do the following:
>>User logs in, password is compared with database, then user can see a
>>list of files in "his" directory (which only he can have access to) and
>>download them. For every user there is a separate directory with
>>different files.
>>Login and all the rest ist done with JSP and working, my problem is I
>>just don'T have any idea how to solve the problem with the
>>directories/files and downloading them. I would really appreciate any
>>help like code samples, links, .. whatever

>
>
> Are you already using a database? Do you have a record for each user
> account in the database? Or do you prefer to use filesystem storage?
> You'll need to be more specific about your design.
>

Well there is a user-database already, which stores usernames,
passwords,... for each user. But the files themselves should be stored
in the Filesystem.

 
Reply With Quote
 
Wendy S
Guest
Posts: n/a
 
      07-22-2003
"Kasper M. Nowak" <(E-Mail Removed)> wrote
> Well there is a user-database already, which stores usernames,
> passwords,... for each user. But the files themselves should be stored
> in the Filesystem.


Once the user logs in and you know his userid, can you construct the URL and
the path for the directory the file lives in?

Then you can get a list of the files (see java.io.File)? If so, you can
iterate through the list of files and tack on the known "first part" of the
URL.

--
Wendy in Chandler, AZ



 
Reply With Quote
 
Wendy S
Guest
Posts: n/a
 
      07-22-2003
"Kasper M. Nowak" <(E-Mail Removed)> wrote
> If I understand rightly what you mean, I'd have to allow acces to the
> user-file directories with a http server, which is very insecure,
> because you just have to type in the exact URL of a file into your
> webbrowser to download it without any authorization, that's why I can't
> use this solution...


Okay, then how about a Servlet that takes the userid/filename as parameters
and then streams the file back at the browser.

The URLs you present as the files to be downloaded are mapped to that
Servlet, it figures out which file, and sends it back.

--
Wendy in Chandler AZ



 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      07-22-2003
Kasper M. Nowak wrote:
> Wendy S wrote:
> > Once the user logs in and you know his userid, can you construct the URL and
> > the path for the directory the file lives in?
> >
> > Then you can get a list of the files (see java.io.File)? If so, you can
> > iterate through the list of files and tack on the known "first part" of the
> > URL.


> If I understand rightly what you mean, I'd have to allow acces to the
> user-file directories with a http server, which is very insecure,
> because you just have to type in the exact URL of a file into your
> webbrowser to download it without any authorization, that's why I can't
> use this solution...


Okay, so write a servlet to handle it. Use request.getPathInfo() to
retrieve the directory name. Perform your security validation before
returning the result.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring a variable in one JSP file and accessing it in another JSP file anubhakhurana@gmail.com Java 8 10-11-2006 01:15 AM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
problem with code download file - two window file download Sam -- ASP .Net 2 03-17-2005 04:20 PM
File upload/download from database. Download appends aspx page to end of file Ryan Taylor ASP .Net 2 11-10-2004 08:31 PM



Advertisments