This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File upload in jsf

 
karmegam shiva
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just struggling with a question, that is i want to upload a file via browse option, in that case in html we will use <input type="file" name="upload"> it's fine , Similarly is any tag is available in JSF to choose file with it's whole path

I am looking for answer for this, if you do, you will be really appreciated
 
K. Tsang
Bartender
Posts: 3441
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

There isn't a tag for file upload. Yet there are open libraries like tomahawk (the t:inputFileUpload) or primeface (p:fileUpload). IF you use RichFaces or ICEFaces maybe they have similar tags too.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Tsang said, there is no support for fileupload via a core JSF tag, although many of the third-party extension tagsets have some sort of fileupload control.

As far as getting the option to "choose file with it's whole path" goes, that depends on what you mean. I don't think that you can make the server pre-select the user's source directory in the fileupload dialog for the simple reason that there is no way for the server to deduce the remote user's file system organization to know what directories are available and where. I don't even have a "C:" drive, for example.

If you are referring to having the entire client filesystem path get set to the server by the client application (browser) as part of an upload submit, that is a feature of Internet Explorer. Many other browsers and OS's only send the basic filename without directory information. Which is more secure, as an unscrupulous web application could learn things about a client's disk layout that could be exploited. Then again, IE didn't exactly win many awards for making hard to attack other people's computers.
 
karmegam shiva
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ holloway

Thanks for your valuable points, i got some idea in that,

The problem of mine is , i need to verify the path of client machine , so now i got a solution which is i am forcing client to enter the file name path in Text field rather than via browse option , so i can get the value of Text field easily.



Thanks

Regards
karmega siva
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, however, informing the server about the directory structure of a client machine is a security problem, and many web browsers will not provide it. IE is an exception. IE is not as popular as it used to be, and I cannot even confirm that all versions of IE will pass the directory pathname, since, as I said, that's revealing sensitive information about the client.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic