Basically my task is to create/download an excel file on click of a button and also to send it to another Api.
Creating excel is not an issue, problem is I don’t understand how to store this get bytes of this excel to send further to Api.
I am restricted, I cannot use third party jars like apache Poi etc.
So currently I am simply using a
jsp.
On click of a button I am calling a 2nd jsp
1 jsp has something like this
generateExcel( ) {
Location.href=“some path for second jsp”;
}
2 jsp has table structure which will display in excel
Besides that have added following in response to make it download as excel
response.setContentType("application/xls");
response.setHeader("Content-Disposition", "attachment; filename=" + "new.xls");
So 2nd jsp has 2 parts 1 is html which shows inside excel and the response header setting part which tells browser to download this jsp as excel.
Now my problem is how to send this excel to Api. Is it possible to get bytes/or base64
string from servletOutputStream before download.
I want Something like
response.getOutPutStream().getBytes// how to make this work