How to configure the Download file button in jsp page design?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • leninbecse
    New Member
    • Aug 2010
    • 15

    #1

    How to configure the Download file button in jsp page design?

    I am using the Database and get values from result set and stored it as string buffer..i am trying to access string buffer value in function(javasc ript) but displays the error..can you please help me to resolve the problem..attach ed my code here..


    <script type="text/javascript">
    function download(){<%
    //Exporting the data
    if(sb1 !=null){
    response.setHea der("Content-Disposition","a ttachment; filename=status sheet.xls");
    response.setHea der("cache-control", "no-cache");
    ServletOutputSt ream outs = response.getOut putStream();
    InputStream fileInputStream = new ByteArrayInputS tream(sb1.toStr ing().getBytes( "UTF-8"));

    byte[] outputByte = new byte[4096];
    //copy binary contect to output stream
    while(fileInput Stream.read(out putByte, 0, 4096) != -1)
    {
    outs.write(outp utByte, 0, 4096);
    }
    outs.flush();
    outs.close();
    }%>
    </script>
Working...