I am developing a web-app where I want to provide a download link to users – so they can download a zip file from my server.
Now, my requirement is that I want to execute some processing logic contained in a servlet before displaying the file dialog to the user for ‘zip’ files.
So If I write
<a href="abc.zip".......>
then it opens a file dialog asking the user to select the location where this file can be saved
But if I want a servlet’s doGet method to do some preprocessing – say like building the zip file , then how can I first call the servlet and then open the file dialog.
Will the following snippet work?
<a href="MyHandlerServlet;abc.zip".......>
Thanks for your help !!
I would rather pass the filename as pathinfo instead of request parameter, e.g.
Otherwise a certain widely used webbrowser developed by a team in Redmond (cough) would use
MyHandlerServletas filename during Save As. When passing the filename as pathinfo, you can obtain the requested file in the servlet by:You only need to map the servlet on
/MyHandlerServlet/*instead of/MyHandlerServlet. Also see this basic servlet example.