posted 15 years ago
Hi Eric,
i am using the below piece of code to flush the data in the specified format.
when i click on submit button i will call on javascript method with the following.
window.open( urlContextValue+"/action.do?mode=generateReport","newwindow");
in .js i am caling generateReport action method. it will go to action method and do the rest of the work.
public ActionForward generateReport(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
if("Excel".equals(FormatType)){
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment; filename= reprot.xls ");
}else if ("RPT".equals(FormatType)){
response.setContentType("application/x-rpt");
response.setHeader(Content-disposition", "attachment; filename= reprot.rpt");
}
byte[] backupDoc = VO.getContent();
ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(backupDoc, 0, backupDoc.length);
outputStream.flush();
outputStream.close();
return null;
}
whenever i clcik on the submit button i want to open in new window if it is rpt. otherwise need to ask open, save, and close. to open PDF, Excel, and XML.
thanks for your response Eric.
Regards,
Purushotham