I think you are trying to solve the wrong problem. It seems you are trying to create a file on the server everytime the user requests some information. but if more than one person requests information at the same time, the routine fails because you can only have one file with that name.
Rather than trying to figure out a way to allow multiple users to create and download this file, I think
you should look at doing this without creating a file at all.
When the user clicks on the link as you indicate, that should run a servlet. The servlet processes the information, sets the content-type to the type of data it will be sending, and then sends the data. In most cases, the content-type is set to 'text/html' and you return HTML code. But you can return any data as long as the content-type is set properly and the data matches that type.
There are any number of packages available that let you create
word , PDF, and excel objects from within
Java. Inside your servlet you set the content-type and the header to match what you are sending. You then write that object to the response output stream. Instead of writing the data to a file on the server, you send it directly to the user.
To the user it looks like they are downloading a file, when the file never actually existed. You generated it on the fly.
For reference, these are the parts of the servlet that you will need to set.
Set the content type to the correct value for what you are sending. In the header you can provide the filename that the user sees when the browser gets the data. The getOutputStream returns the stream that is going to the requestor. Just send your object there.
There is a lot more to this, but you should be able to find a lot of information on the web and piece it together to meet your needs.
Hope that helps.