• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Browsing for file Path

 
Daniel Browne
Greenhorn
Posts: 5
Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to create a web application in JSF which allows the users to save and
load to a text file. I would like to provide the "open" and "save as" functions
similar to those found in word documents so that the file path can be found and
added as a String. Is this possible and how would you go about achieving it?

Thanks
 
Paul Clapham
Sheriff
Pie
Posts: 20739
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't possible for web applications to interact with the client's file system. If that's what you meant. It might be possible for your application to implement a virtual file system using files on the server, but I don't know if that was your question.
 
Daniel Browne
Greenhorn
Posts: 5
Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I'll see if I can't explain what I'm trying to do a bit better.

The application saves variable to a text file which can be loaded if the web application is run again. The problem is that the user has to specify the complete file path such as:
"C:\Users\username\Documents\file.txt"

So I was hoping there would be something available similar to the "save as" function found in word so that the user can specify where on their computer they wish to save the text file making it easier for them to find the file when loading it again.
 
Paul Clapham
Sheriff
Pie
Posts: 20739
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Browne wrote:The application saves variable to a text file which can be loaded if the web application is run again.


And how exactly does it do that?
 
Daniel Browne
Greenhorn
Posts: 5
Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added a function in the bean that writes all the required variables to a text file. Then when it comes to loading the file again I have another function that loads the variables in the correct order and reproduces the end result of the application that was saved.
 
Paul Clapham
Sheriff
Pie
Posts: 20739
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. So that answers my question: you are saving the data to a file on the server, not to a file on the client's machine.

So yeah, presumably you could write something in JSF which uses some beans to allow the user to choose a location on your server. You're going to want to put some restrictions on exactly where they can save, you don't want people fishing through your server and trampling on files which ought to be left alone.

Or better still, don't give them the choice at all. Make them save in a specific directory on your folder. This prevents the security exposure you would get by allowing the user to choose a folder and as a bonus it makes your requirement go away.
 
Daniel Browne
Greenhorn
Posts: 5
Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, I was trying to design it so that the user could save it to on their own computer, and load it from whereever they may have saved it.
I tried creating a file to hold the text files being generated but unless I specified the complete file path it doesn't work and I can't program that into the bean as when I move the program from one computer to another the file path changes.
 
Paul Clapham
Sheriff
Pie
Posts: 20739
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:It isn't possible for web applications to interact with the client's file system.


Although that isn't quite correct. If you use trusted components, like for example a signed applet, then they can. But in general you don't want to connect to a web application and find it has access to everything on your computer. You really don't. Think about it in the context of security.
 
Daniel Browne
Greenhorn
Posts: 5
Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic