aspose file tools*
The moose likes JSP and the fly likes file download method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "file download method" Watch "file download method" New topic
Author

file download method

g forte
Greenhorn

Joined: Aug 28, 2003
Posts: 25
I have the following file download code that I am trying to create a method out of:

This works but I need to somehow create one method from this all or create a method from the 6 lines of code:

I need to be able to call this method from an onClick event so that the download dialog box is activated when the user clicks on a button.
TIA!
Torsten Schippel
Ranch Hand

Joined: May 09, 2003
Posts: 62
Hi,
you have to differ between client side and server side code. Your writeTheFileToStream method is only accessible on the server side (inside of your JSP). So you can't call it from the javascript onclick event.
I would recommend a servlet. Place your code in servlet and call it by URL inside of the javascript function.
Regards
Torsten
g forte
Greenhorn

Joined: Aug 28, 2003
Posts: 25
So theres no way to prevent this code from running onLoad? Basically If I have the code on my jsp the download dialog box opens as soon as the page loads(which I dont want). Is there not a way to call this method on demand within a jsp?
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: file download method