Bookmark Topic Watch Topic
  • New Topic

How do I execute a file download from JSP

 
P.Jamieson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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
 
g forte
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64716
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64716
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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