Get file path from the client

Discussion in 'Java' started by Sathyaish, Dec 12, 2006.

  1. Sathyaish

    Sathyaish Guest

    I am not a Java programmer and I have a question about a web
    programming scenario in Java. Can you please tell me if it is possible
    for the server to retrieve the file name and path of a file selected by
    a user on the client machine using the Save file dialog control built
    into Windows?

    Here's the scenario.There's a button called OK. When it is clicked, a
    Save file dialog (the windows common dialog that lets you select a file
    to open or save) pops up on the client. The user chooses a file name
    and location to save a new file. In the click of the same button,
    records from a database are then transferred to the client machine in
    that location with that file name.

    In ASP.NET I know it would be possible because the OK button's click
    event handler would execute on the server because it'd be a server
    control. And so it'd look something like this in ASP.NET:

    public void btnOK_Click(object sender, EventArgs e)
    {
    //psuedocode
    string sPath = FileDialog.Show();

    //sPath is the location and name of the file on the client's hard
    drive
    }


    Is it possible in Java?
     
    Sathyaish, Dec 12, 2006
    #1
    1. Advertising

  2. Sathyaish

    Sathyaish Guest

    > public void btnOK_Click(object sender, EventArgs e)
    > {
    > //psuedocode
    > string sPath = FileDialog.Show();
    >
    > //sPath is the location and name of the file on the client's hard
    > drive
    > }



    Just to pick a nit, I wrote the wrong psuedocode for ASP.NET, I
    realize. The filedialog returns a DialogResult and not a filename. The
    file name can be known from the filedialog's FileName property, so it'd
    look more like:

    public void btnOK_Click(object sender, EventArgs e)
    {
    //psuedocode
    FileDialog.Show();
    string sPath = FileDialog.FileName();

    //sPath is the location and name of the file on the client's hard
    drive
    }

    or something like that. So, it is possible in ASP.NET. Is it possible
    in Java/JSP/whatever?
     
    Sathyaish, Dec 12, 2006
    #2
    1. Advertising

  3. Sathyaish

    Oliver Wong Guest

    "Sathyaish" <> wrote in message
    news:...
    >> public void btnOK_Click(object sender, EventArgs e)
    >> {
    >> //psuedocode
    >> string sPath = FileDialog.Show();
    >>
    >> //sPath is the location and name of the file on the client's hard
    >> drive
    >> }

    >
    >
    > Just to pick a nit, I wrote the wrong psuedocode for ASP.NET, I
    > realize. The filedialog returns a DialogResult and not a filename. The
    > file name can be known from the filedialog's FileName property, so it'd
    > look more like:
    >
    > public void btnOK_Click(object sender, EventArgs e)
    > {
    > //psuedocode
    > FileDialog.Show();
    > string sPath = FileDialog.FileName();
    >
    > //sPath is the location and name of the file on the client's hard
    > drive
    > }
    >
    > or something like that. So, it is possible in ASP.NET. Is it possible
    > in Java/JSP/whatever?


    I am shocked that this is possible via ASP.NET. Can you post a link to
    an ASP.NET page which just gives me a file save dialog, and then I'll try
    saving it somewhere, and then your page tells me the filename of the file I
    saved it to? I can't bring myself to believe that ASP.NET would provide such
    a privacy breach. I'm expecting for the code on the serverside to throw some
    sort of security exception or something like that. I really have to see this
    for myself.

    - Oliver
     
    Oliver Wong, Dec 12, 2006
    #3
    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. James
    Replies:
    2
    Views:
    13,932
    Andrew Thompson
    Dec 7, 2004
  2. Replies:
    1
    Views:
    595
    Oliver Wong
    Jul 13, 2006
  3. Oren
    Replies:
    1
    Views:
    558
    Michael D. Ober
    Apr 29, 2007
  4. marss
    Replies:
    5
    Views:
    1,015
    marss
    Sep 13, 2007
  5. dude
    Replies:
    5
    Views:
    1,743
    Jussi Piitulainen
    Mar 17, 2011
Loading...

Share This Page