Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

requested resource is not available  RSS feed

 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a jsp page in which the user selects a file then he clicks on
a download button, the action of the download button does this:



Here is my web.xml


Why am I getting a requested resource is not available?

Thanks,

Sonia
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File downloads are not controlled by the server. In fact, for security reasons, the whole HTTP architecture is such that no HTTP server (Java or otherwise) can suck a file off a client.

Instead, you have to make the client send the file to the server. That means you have to create a web page with a multi-part form and a file upload control on it. When you select a file to upload and submit the form, the client will mime-encode the contents of the selected file for Internet transmission and include it as part of the submitted form data.

When you're using JSF to receive uploaded files, the API will provide a way to access the uploaded data. For portability's sake the data is considered as "pure" data at that point, and doesn't have a disk file association, although very commonly the server code will then create a new File and copy the data stream into it in order to create a permanent file.

2 caveats:

1. DON'T upload files into the WAR. Just because you can (sometimes) doesn't mean you should. Use a directory that's outside the WAR to hold uploaded file data.

2. DON'T assume that the filename that you're sent is an absolute pathname. If the client was Internet Explorer, it probably will be, but other browsers will generally send a relative pathname.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!