java - download file instead of opening in browser using struts2 -


i have written file upload , download in struts2. while download text.pdf file opened in browser page, how download files instead of open in browsers page?

<div class="block-fluid table-sorting clearfix">     <table cellpadding="0" cellspacing="0" width="100%" class="table" id="tsortable">         <thead>             <tr>                 <th>s. no</th>                 <th>account no</th>                 <th>file </th>                 <th>action</th>             </tr>         </thead>         <tbody>             <s:iterator value="fileuploadlist" status="rowstatus" >                 <tr>                                                <td><s:property value="#rowstatus.index+1" /></td>                     <td><s:property value="fileupload_temp2" /></td>                     <td><s:property value="fileupload_filename"/></td>                                                         <td><s:a href="%{fileupload_filepath}" target="_blank" >download</s:a> </td>                  </tr>             </s:iterator>         </tbody>     </table> </div> 

you can force downloading, have from server side: implement own endpoint (a servlet, example) returns header along requested file:

content-disposition: attachment; filename="suggested-filename" 

http://www.w3.org/protocols/rfc2616/rfc2616-sec19.html


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -