• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to create an HTML form in JSP for downloading files?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I understand how to create a form of type "multipart/form-data" that uploads a file from a client's box , but I am trying to use the same form code for downloading a file to a client's box .

Using the code below, the value of input named "downloadFileInput" should have "test.txt", but it is blank. If I try to use the "Browse" panel that pops up and provide it a file name of "test.txt", it returns a message that that file does not exist.

What is wrong with this HTML code within JSP file?



Thanks,
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand. If you want to download a file from the server, you just copy the file to the response. There isn't any HTML required to do that, only a link to something which will return the file as its response.

And preferably you wouldn't use a JSP to do that, since JSP is meant to generate HTML. If you're returning a file rather than an HTML page, you should use a servlet to return the file.

Or were you thinking that via this form, you could tell the browser where to put the file, so that the user wouldn't have to answer that question? Nope. That would be a serious security violation.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Form? For download?
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect this is for hacking reasons
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jhon masco wrote: I suspect this is for hacking reasons


I suspect not, because that doesn't make any sense.

Ultimately I think the OP is looking for a way to select a file from the server for download. But it's kind of hard to say. But as mentioned, form submissions go from the client to the server--nothing to do with downloading.

What precisely are you looking for? How to navigate files on the server?
reply
    Bookmark Topic Watch Topic
  • New Topic