Originally posted by vishalraju shah:
If you are populating collection from DB -> coming to servelt -> going to jsp than following can be one of the way you can achieve your requirement.
<%@ page contentType="text/csv"%>
<% response.setHeader("Content-Disposition","inline; attachment; filename=Data.csv");
response.setHeader( "Pragma", "public" );
String separator = System.getProperty("line.separator");
// iterate over your collection and print values seperate by ,(comma).
// This will prompt user to open/save a csv file.
Originally posted by Abhinav Srivastava:
This is one way of Exporting to Excel:
"If users want to save the page as a PDF file or Excel file"
POI and iText are the more elegent solution and I agree to that. However if user here wanted to just save file in excel/pdf format which can be done by above way as per me.
Originally posted by Glenn Graham:
The reason this does work is that the browser now interprets all the tag and data content as Excel info.