How to read the file from client machine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhoriya22
    Contributor
    • Jul 2007
    • 251

    #1

    How to read the file from client machine

    Hi,
    I am using jsp and servlets in my application. In this application I am reading contents of *.csv files and uploading them to database.
    Now this thing is working fine when I am running my application on single machine(sever and client). But when I am running my application on other machines(client ) I am not able to read the files(*.csv). It is throwing FileNotFoundExc eption.
    How should I read the file from client machine. Can MIME be helpful in this regard.
    Last edited by madhoriya22; Sep 10 '07, 08:04 AM. Reason: To Add my signature :)
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by madhoriya22
    Hi,
    I am using jsp and servlets in my application. In this application I am reading contents of *.csv files and uploading them to database.
    Now this thing is working fine when I am running my application on single machine(sever and client). But when I am running my application on other machines(client ) I am not able to read the files(*.csv). It is throwing FileNotFoundExc eption.
    How should I read the file from client machine. Can MIME be helpful in this regard.
    How are you specifying the path then?

    Comment

    • madhoriya22
      Contributor
      • Jul 2007
      • 251

      #3
      Originally posted by r035198x
      How are you specifying the path then?
      Hi,
      Right now in my jsp page I have put this ..
      Code:
       
      <input type="file" name="CSVFilePath" />
      I am getting the path from this file select option ..
      Code:
       
      String path = request.getParameter("CSVFilePath");
      and passing it to the function...
      Code:
       
      boolean b = defectDetailDAO.uploadCSVfileIntoDataTable(filePath)
      But doing same thing from client machine it is throwing FileNotFoundExc eption.
      Last edited by madhoriya22; Sep 10 '07, 08:39 AM. Reason: To add my signature :)

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        Originally posted by madhoriya22
        Hi,
        Right now in my jsp page I have put this ..
        Code:
         
        <input type="file" name="CSVFilePath" />
        I am getting the path from this file select option ..
        Code:
         
        String path = request.getParameter("CSVFilePath");
        and passing it to the function...
        Code:
         
        boolean b = defectDetailDAO.uploadCSVfileIntoDataTable(filePath)
        But doing same thing from client machine it is throwing FileNotFoundExc eption.
        Is that CSV file on the client or the server? Cause, if it's on the client, that's probably the problem, as JSP is server based and will therefore look for the file on the server.

        Greetings,
        Nepomuk

        Comment

        • madhoriya22
          Contributor
          • Jul 2007
          • 251

          #5
          Originally posted by nepomuk
          Is that CSV file on the client or the server? Cause, if it's on the client, that's probably the problem, as JSP is server based and will therefore look for the file on the server.

          Greetings,
          Nepomuk
          Hi,
          CSV file I am selecting from the client machine .

          Comment

          • Nepomuk
            Recognized Expert Specialist
            • Aug 2007
            • 3111

            #6
            Originally posted by madhoriya22
            Hi,
            CSV file I am selecting from the client machine .
            In that case I guess you'll have to upload it to the server first. The server probably won't be able to find it, because it's searching for a local file, while the file you want isn't local.

            Greetings,
            Nepomuk

            Comment

            • madhoriya22
              Contributor
              • Jul 2007
              • 251

              #7
              Originally posted by nepomuk
              In that case I guess you'll have to upload it to the server first. The server probably won't be able to find it, because it's searching for a local file, while the file you want isn't local.

              Greetings,
              Nepomuk
              Hi,
              Any Idea how to do that ? Just starting point :)
              Last edited by madhoriya22; Sep 10 '07, 09:37 AM. Reason: To add my signature :)

              Comment

              • Nepomuk
                Recognized Expert Specialist
                • Aug 2007
                • 3111

                #8
                Originally posted by madhoriya22
                Hi,
                Any Idea how to do that ? Just starting point :)
                I don't think it's a good idea (if possible) to upload it with Java, but there are alternatives... By searching the forum, I found this. ^^

                Greetings,
                Nepomuk

                Comment

                • madhoriya22
                  Contributor
                  • Jul 2007
                  • 251

                  #9
                  Originally posted by nepomuk
                  I don't think it's a good idea (if possible) to upload it with Java, but there are alternatives... By searching the forum, I found this. ^^

                  Greetings,
                  Nepomuk
                  Hi,
                  I am not using JavaScript/Ajax. I have to done it in java.
                  Any help :(
                  Last edited by madhoriya22; Sep 10 '07, 10:19 AM. Reason: To add my signature :)

                  Comment

                  • Nepomuk
                    Recognized Expert Specialist
                    • Aug 2007
                    • 3111

                    #10
                    Originally posted by madhoriya22
                    Hi,
                    I am not using JavaScript/Ajax. I have to done it in java.
                    Any help :(
                    Can't you just have a little bit of JavaScript/Ajax for that task in the page, which also loads the JSP? Otherwise I guess you have a problem, as the only way with Java I can think of is by having the user install a piece of software on the client. THEN you could work with sockets. However, very few people would want to do that.

                    Greetings,
                    Nepomuk

                    Comment

                    Working...