If you mean a text format like CSV, you'll have to use the Apache POI package to turn that CSV into an excel sheet. You may need to implement that conversion yourself.
http://jakarta.apache.org/poi/index.html
As for the download, you'll need to do the conversion and then get the byte output, which you output to the browser. Using HTTP headers you can control if the file is opened inside the browser or downloaded, and which filename that the file will get. To force a download box, use the following headers:
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment; filename=\"FILENAME\"");
response.setContentLength(LENGTH_IN_BYTES);
<output excel content to browser here>
In the above code you need to replace FILENAME and LENGTH_IN_BYTES with the filename you want the excel file to have, and the size of that excel file in bytes.
If you want more information, search this forum. JSP/servlet file download questions get asked almost every day.