1

I have this scenario. I have a JSP page(First.jsp) in which I have my buttons. I am including another JSP page(Second.jsp) in First.jsp which contains an image. When I click on a button in my First.jsp, I want the image in Second.jsp to be downloaded. How can I do this? I have the following which downloads the image in the same page. DEMO

        <div id="download">
            <img src="http://www.glamquotes.com/wp-content/uploads/2011/11/smile.jpg" id="image" />
           <a class="button" href="http://www.glamquotes.com/wp-content/uploads/2011/11/smile.jpg" download="smile.jpg">Download image</a>
        </div>

CSS:

    #image{
      height:250px;
      width:250px;
      float:left;
    }
    #dwnld{
      float:left;
    }

   .button {
     appearance: button;
     -moz-appearance: button;
     -webkit-appearance: button;
     text-decoration: none; font: menu; color: ButtonText;
     display: inline-block; padding: 2px 8px;
     font-size: 15px;
    }
Benny
  • 521
  • 3
  • 8
  • 21
  • Sorry; "downloaded"; you mean to the one of the .jsp pages, or download to the users computer :-S ? – benteh Sep 21 '13 at 15:03
  • the image is in one jsp and the image is in another jsp. When the user clicks on button, the image should be saved onto the user's machine – Benny Sep 21 '13 at 15:07
  • So you want a force download? Something like this? http://stackoverflow.com/questions/2598658/how-to-force-a-pdf-download-automatically – benteh Sep 21 '13 at 16:14
  • I want exactly the same thing which is in my demo fiddle. – Benny Sep 22 '13 at 09:09
  • Sorry; but if you can do it in fiddle, it surely must be other code that prevent this? – benteh Sep 22 '13 at 13:09
  • in the fiddle, I have the button and image on the same page. In actual code, I have button in one JSP page and image comes from another JSP page. – Benny Sep 23 '13 at 04:55

0 Answers0