I am working on a web application using the Struts framework. Using a form on a jsp page, I generate a report which is displayed in pdf on a new screen. The report is generated through an Action class method. I would like to display a "Please wait" screen while the report is being generated.

The action class method calls functions that generate a pdf file and then redirects control to that file. So I cannot use the flush() method to send html to the browser while the report is being generated (once a response is committed it cannot be written to again). Neither can I use the 'div' tag method as my new page is not a jsp page (it is a new browser window with pdf file displayed inside it).

My code is shown below....

//the jsp code calling the action
<nested:form action="" target="_blank">


// The Action class
public ActionForward getTransactionReports(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception
{

ICustomerAdministrationClient admin_impl = getCustomerAdministrationService(request);

//enforce user permission
enforceFeaturePermissions(EMSConstants.FEATURE_REPORTS, request, 1);

EMSBaseAdminForm admin_form = (EMSBaseAdminForm)form;
ReportsForm reportsForm = admin_form.getReportsForm();

//cant do this as it creates an IllegalStateException
// PrintWriter html = response.getWriter();
//
// html.print("<html>\n<head><title>my test</title></head>\n<body>");
// html.print("<p><img src="">// html.flush();
// html.close();


//if details type is summary then output format can only be PDF
if(reportsForm.getDetailsType().equals(EMSConstants.REPORTS_SUMMARY))
reportsForm.setOutputFormat(EMSConstants.REPORTS_FORMAT_PDF);

//generate the reports using jasper reports
doJasperReports(reportsForm, request);

CustomerForm customer_form = (CustomerForm)getSessionObject(request, "customerForm");
Collection all_region_list_forms = (Collection)getSessionObject(request, "allRegionListForms");

admin_form.setCustomerForm(customer_form);
admin_form.setRegionListForms(all_region_list_forms);
request.setAttribute(EMSConstants.FORM_VIEW, admin_form);

String relativePath = File.separator + "temp_" + request.getSession().getId();
String pdfFilePath = File.separator + "temp" + relativePath + File.separator + "ReportinPDF.pdf";
String csvFilePath = File.separator + "temp" + relativePath + File.separator + "ReportinCSV.dpt";

if(reportsForm.getOutputFormat().equals(EMSConstants.REPORTS_FORMAT_PDF))
return (new ActionForward(pdfFilePath, true));

return (new ActionForward(csvFilePath, true));
}


Any help would be appreciated. Thanks.

Digital Payment Technologies Corp.

  

Rizwan Merchant - Software Developer
4105 Grandview Highway, Burnaby, BC, V5C 6B4, Canada
Email:        [EMAIL PROTECTED]
Phone:       604-688-1959 x243   Fax: 604-687-4329    
Toll Free:    1-888-687-6822       
Website:    www.digitalpaytech.com


 

Reply via email to