• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file download method

 
g forte
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic