Using the output stream to provide file downloads in your project is too much trouble, and if you use the WebLogic Web application server in your project, we can use the Virtual directory Mapping feature provided in WebLogic, which is very handy for file download services.
1. Create a new Web application and set its context path, for example: download
2. New Weblogic.xml under Web-inf
<?xml Version = ' 1.0 ' encoding = ' UTF-8 '?> <weblogic-web-app ' xmlns:xsi=
Xmlschema-instance "
xsi:schemalocation=" Http://www.bea.com/ns/weblogic/weblogic-web-app
http:// Www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd "
xmlns=" http://www.bea.com/ns/weblogic/ Weblogic-web-app ">
<virtual-directory-mapping>
<!--local path-->
<local-path>f:/ Resources</local-path>
<!--URL matching-->
<url-pattern>/*</url-pattern>
</ Virtual-directory-mapping>
</weblogic-web-app>
3. Deploy this Web application and use the download feature:
If you have a A.doc file under the local path you configured, you can download the file by using the link http://localhost/download/A.doc.