use of apache common VFS

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

use of apache common VFS

Hardik Shah
hi
i am newbie of apache common vfs

i have developed one web application which works currently on lan
in my apps one module i have do such that
using html tag input type=file, i have input a path value of the file resides on client computer
at the bean side i have wrote fuction flieheader and call through jsp
---------------------------------------------------------------------------------------------
 public boolean fileheadr(String fname)
{
    File file = new File(fname);
            try {
              fis = new FileInputStream(file);
              // Here BufferedInputStream is added for fast reading.
              bis=null;
              dis=null;
              headr=null;
              isheadr=false;
              bis = new BufferedInputStream(fis);
              dis = new DataInputStream(bis);
             
              if(dis.available() !=0)
             
              {  
             // dis.available() returns 0 if the file does not have more lines.
             //while (dis.available() != 0) {

             // this statement reads the line from the file and print it to
              // the console.
                 headr=dis.readLine();
                  //}
                 if(headr.equalsIgnoreCase("Sim Msisdn Mrp"))
                 {
                isheadr=true;
                // headr="right";
                 }
              // dispose all the resources after using them.
              }
                 fis.close();
                 bis.close();
                 dis.close();
             
            }
            catch (FileNotFoundException e)
            {
              e.printStackTrace();
            }
            catch (IOException e)
            {
              e.printStackTrace();
            }
           
            return isheadr;
        }
--------------------------------------------------------------------------------------------
but it gives error in server logs java.io.filenotfound exception ,beacuse server try to find particular file in
its local drive while its on clients local drive

now how can i achieve solution of this problem using vfs

please help me
 
Reply | Threaded
Open this post in threaded view
|

RE: use of apache common VFS

Jörg Schaible-2
hns wrote:
> hi
> i am newbie of apache common vfs

apparently not only of vfs ;-)

> i have developed one web application which works currently on lan
> in my apps one module i have do such that
> using html tag input type=file, i have input a path value of the file
> resides on client computer at the bean side i have wrote fuction
> flieheader and call through jsp

[snip]

> but it gives error in server logs java.io.filenotfound
> exception ,beacuse
> server try to find particular file in
> its local drive while its on clients local drive
>
> now how can i achieve solution of this problem using vfs

You cannot. It is not possible to access what is not present. To access a file on the server that is provided by the user, it must be uploaded. This can be done with the browser and follows the description of an RFC. Have a look at commons-fileupload to solve your problem: http://commons.apache.org/fileupload/

- Jörg

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]