I amWhen you click on the link, the ajax code will not sure what yourbe called so the filename parameter will not be included in the request to the servlet do but. The servlet will execute with filename = null. That is the actual result you can lookgot.
To fix this, I think you have to call the ajax code at these thingsthe first time the page loaded so that your servlet can create a file and place it on the server. Then you have to pass filename parameter in your link such as:
Did you declare your servlet and the servlet-mapping (/export.zip) in web.xml?
Try this for passing parameter in your ajax call:
$.ajax({ type: 'post', url: '/export.zip', data: {filename : 'myFile'}, success:function(data){alert(data);}, error:function(){alert('error');} });
<a href="http://yourdomain.com/downloadFile?filename=myFile">Download file</a>
The downloadFile servlet will look for file named myFile.txt which was created at the first time your page loaded with ajax called, and give you the file in response.