J Kj

Greenhorn
+ Follow
since Feb 04, 2023
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by J Kj

I understand it is a weird way, but it is an old project, and I am restricted.I cannot be adding new things to it. So poi jars are not possible.
As per this projects structure there is 1 servlet only which i cannot edit.
Thats why was trying this jsp way. I don’t fully understand it but my thinking was before jsp outputs response i may be able to save this jsp or get bytes out of it. Now I understand it is not possible. Thanks for your reply. I will check if possible to update this project
2 years ago
JSP
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
2 years ago
JSP