Using java servlet i need to do a back-end DB query and populate the results in an excel file and provide to client user. I have a working code of downloading Excel by setting the HtmlServletResponse object's contentType and Header like below:
response.setContentType("application/vnd.ms-excel; charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+ "Report" + ".xls");
But my question is in addition to providing this Excel sheet as a download i also need to send the 'initial search criteria' selected by the user as a HTML. And for html, i need to set the content type like below.
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html");
I think it's not possible to set the content type to 2 different values. How to solve this problem?
To phrase the problem in a different way -- "I have a HTML search form based on which user selects a search criteria - While providing the results in an excel save as file, i need to repopulate the same html so that search criteria selected by user is not lost".
I am new to Servlets and not sure if this is very straight forward. Thanks for the help.