aspose file tools*
The moose likes JSP and the fly likes How do I execute a file download from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

How do I execute a file download from JSP

P.Jamieson
Greenhorn

Joined: Apr 30, 2003
Posts: 21
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

Joined: Aug 28, 2003
Posts: 25
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

Joined: Jan 10, 2002
Posts: 61187
    
  66

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I execute a file download from JSP