wrirting Data to Excel form JSP
I want to write data into 2 tabs of the same excel through JSP. I am using JakartaPOI api for this
this is the code
HSSFWorkbook wb =new HSSFWorkbook();
//creating 2 tabs
HSSFSheet spreadSheet = wb.createSheet("TAB1");
HSSFSheet s1 = wb.createSheet("TAB2");
HSSFRow row = spreadSheet.createRow(0);
HSSFCell cell = row.createCell((short) 0);
HSSFRow row1= s1.createRow(0);
HSSFCell cell1 = row1.createCell((short) 0);
FileOutputStream output =new FileOutputStream(new File("Users.xls"));
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-
Disposition", "attachment;filename=Users.xls");
ServletOutputStream servletOutputStream =
response.getOutputStream();
wb.write(servletOutputStream);
servletOutputStream.close();
This code works fine and through this i am able to open a excel woth two tabs.But in the background "IllegalStateException" is thrown.
Reson for the Exception:In the jsp page there is the implicit "out" object which is the PrintWriter object which in turn is a character stream object .Using one "response" we can get only one stream object which the already available out object but am in need of byte stream object to writer the excel file into the response stream.
Please somebody can tell is there a ohter method to create excel sheet with two tabs through JSP.

