• Post Reply Bookmark Topic Watch Topic
  • New Topic

upload file with path stored in database jsf

 
fatima zahra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm using jsf 2 to upload file, first I upload the file in a system directory, then trying to store the path to database with other information, my stuck is that when submitting I upload the file successfully, find it in the right place, find the other information such as description, file name ... in database but don't find the path. this is my managed bean :


my Dao to store info about the uploaded file

last my xhtml page :


any help please and thanks in advance
 
Tim Holloway
Bartender
Posts: 18419
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helpful hint #1: When posting examples, please minimize the samples to just the parts that you think relate to the problem. It's very hard to read long bits of code and XML on-screen, and since no one here gets paid, they're not likely to want to print it off and read it.

Helpful hint #2: Java supports a "universal" file path format. Use it in preference to OS-specific forms both to assist in code portability and because it doesn't use backslashes, which are very treacherous in Java.

So instead of


Code this:


Note that as a general rule, you should not read, write, or create files within the webapp server or WAR directories. ESPECIALLY do not create, write, update or delete files inside the WAR itself. Use an external directory!

I am not sure what you mean about the path, though. If you're looking to do something with the path of the file as it is stored on the client, you should be aware that most web browsers do not send that path, with the exception of Internet Explorer. It's a security risk in that it publishes hints about the structure of the client's filesystem. Plus, since client and server cannot do actual file I/O with each other, it's useless. HTTP file upload/download doesn't do file I/O over the network. Instead it simply embeds the data contents of the file into an HTTP request or response data stream.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!