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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How do I execute a file download from JSP

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I would like to have a file download in my web application. I am using a JSP page for processing requests. As part a user request is to initiate a file download. I just want to have a bit more control of downloading rather than inputting a hyperlink into the browser. At the moment I do not have FTP and probably will not for now, thanks
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I have a jsp called test.jsp, the only code on this page is:

In the page that I want to initiate the download dialog I use this:

I am attempting to create a class file from this code so I dont have to call the test.jsp page. If you are going to create a class file from this maybe you could reply back with the code.
 
Sheriff
Posts: 67645
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:
  • Report post to moderator
What kind of control are you trying to exert? Whether you let the server send up the file or filter it through your JSP or servlet (see below) it's still going to act pretty much the same. The major advantage that a servlet (see below) will give you is the ability to map the file to a non-specific url, or to be smart about which file to download based upon varying criteria.
But once returned to the browser, you'll get all the 'normal' file download behavior. So what exactly are you trying to do?
And... a JSP is a poor choice for this. Much better to use a servlet. JSPs are designed to deliver text data and you may run into problems (as many other who have posted on this board have) trying to cajole it into behaving when delivering non-text files.
hth,
bear
 
Bear Bibeault
Sheriff
Posts: 67645
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:
  • Report post to moderator
Ah, I just discovered that you had posted the same question in the Servlet forum.
Please do not cross-post the same question in multiple forums. It creates redundant conversations and wastes peoples' time.
Please continue any discussion here.
bear
JSP Forum Bartender
 
    Bookmark Topic Watch Topic
  • New Topic