JSP file download

Discussion in 'Java' started by Kasper M. Nowak, Jul 22, 2003.

  1. 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
     
    Kasper M. Nowak, Jul 22, 2003
    #1
    1. Advertising

  2. Kasper M. Nowak

    Chris Smith Guest

    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
     
    Chris Smith, Jul 22, 2003
    #2
    1. Advertising

  3. 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.
     
    Kasper M. Nowak, Jul 22, 2003
    #3
  4. Kasper M. Nowak

    Wendy S Guest

    "Kasper M. Nowak" <> 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
     
    Wendy S, Jul 22, 2003
    #4
  5. Kasper M. Nowak

    Wendy S Guest

    "Kasper M. Nowak" <> 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
     
    Wendy S, Jul 22, 2003
    #5
  6. Kasper M. Nowak

    Chris Smith Guest

    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
     
    Chris Smith, Jul 22, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Taylor
    Replies:
    2
    Views:
    960
    Ryan Taylor
    Nov 10, 2004
  2. Sam --
    Replies:
    2
    Views:
    628
    Sam --
    Mar 17, 2005
  3. Replies:
    0
    Views:
    4,407
  4. Brett  Kelly
    Replies:
    1
    Views:
    688
    Steve C. Orr [MVP, MCSD]
    Jun 16, 2006
  5. Replies:
    8
    Views:
    3,499
    Manish Pandit
    Oct 11, 2006
Loading...

Share This Page