Can be anywhere from a few seconds to 4-5 minutes, depending on the size of
the report.  

-----Original Message-----
From: Brett Connor [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 23, 2004 10:40 AM
To: Struts Users Mailing List
Subject: Re: Intermediate loading page

Ah. What is a typical length of time for a report generation? I'm inferring
this is a serious resource constraint for your system.


Rizwan Merchant wrote:

>I want the variable to be reset if the browser is closed. The browser could
>be closed while the report generation is in process (which is a separate
>thread). There seems to be no way for the server to know that the browser
>was closed. If I do not reset the session variable then I cannot start
>generating another report until the first report thread dies on the server.

> 
>
>-----Original Message-----
>From: Brett Connor [mailto:[EMAIL PROTECTED] 
>Sent: Friday, July 23, 2004 10:06 AM
>To: Struts Users Mailing List
>Subject: Re: Intermediate loading page
>
>Surely the session variable will be reset by the report generation process,
>independent of any browser windows open, therefore no problem, you never
>need to know if the browser has been closed or not. Or have I
misunderstood?
>
>Brett
>
>Rizwan Merchant wrote:
>
>  
>
>>Thanks for the previous input. I moved the report generation to a 
>>thread and set a session variable which is a boolean indicating that a 
>>report is currently being generated. Once the report generation is 
>>complete that session variable is set to false again.
>>I have come across another problem though. Say a user starts generating 
>>a report. The boolean session variable is set to true. If the user 
>>tries to generate another report while the fist oneis not complete, 
>>then the boolean variable is checked and the user is not allowed to 
>>generate another report (until the first one is complete and the 
>>boolean session variable is set to false).
>>
>>In this scenario, if the user abruptly closes the intermediate page 
>>which is supposed to load the report , then the session variable is 
>>still set to true (indicating report is being generated) as the thread 
>>on the server has not finished running. If the user now tries to create 
>>another report then s/he will not be allowed to do so (until the thread 
>>on the server is done running).
>>
>>So I guess my question is : Is there any way to set a session variable 
>>when the user closes a browser window abruptly?
>>Or is there another way to approach this problem? 
>>
>>Thanks,
>>
>>-Riz.
>>
>>-----Original Message-----
>>From: Craig McClanahan [mailto:[EMAIL PROTECTED]
>>Sent: Friday, July 16, 2004 5:23 PM
>>To: Struts Users Mailing List
>>Subject: Re: Intermediate loading page
>>
>>Rizwan Merchant wrote:
>>
>> 
>>
>>    
>>
>>>Hi Craig,
>>>
>>>Thanks for the reply. I came across this solution, but does this not 
>>>mean that the user will only be able to generate one report at a time 
>>>(since we are storing the flag in the user's session)? If the user 
>>>starts generating a second report which is much smaller than the first 
>>>then would this not create a problem?
>>>
>>>
>>>
>>>   
>>>
>>>      
>>>
>>You could accomodate such a thing in several different ways, but how 
>>would the user even start requesting the second report?  If they're 
>>sitting on the auto-repeat "Please Wait" page, they won't have the 
>>opportunity.  If you want them to be able to go request a second report 
>>while the first one is still generating, you'll probably be better off 
>>just navigating back to the main menu (or something) after firing off 
>>the first thread, then let them fire off a different thread (using a 
>>different flag) for the second report
>>-- then have a screen where they can "pick up" their completed reports 
>>and display them.
>>
>>If the computational effort to produce reports becomes severe, you 
>>might also consider using some sort of job queueing package so that a 
>>single background thread could do the report generation for all your 
>>users (one report at a time).  If you go this way, the "pick up your
>>    
>>
>completed report"
>  
>
>>page becomes an even better idea.
>>
>> 
>>
>>    
>>
>>>Thanks again for your input. Much appreciated.
>>>
>>>-Riz.
>>>
>>>
>>>
>>>   
>>>
>>>      
>>>
>>Craig
>>
>> 
>>
>>    
>>
>>>-----Original Message-----
>>>From: Craig McClanahan [mailto:[EMAIL PROTECTED]
>>>Sent: Friday, July 16, 2004 3:37 PM
>>>To: Struts Users Mailing List
>>>Subject: Re: Intermediate loading page
>>>
>>>Rizwan Merchant wrote:
>>>
>>>
>>>
>>>   
>>>
>>>      
>>>
>>>>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).
>  
>
>>>>  
>>>>
>>>>     
>>>>
>>>>        
>>>>
>>>One common strategy for this sort of thing is to refactor your action 
>>>into several, along the following lines:
>>>
>>>* The Action that is currently creating the PDF should instead  fire 
>>>off a background thread to do the report preparation.  It  will then 
>>>forward to a "Please Wait" page (see below).
>>>
>>>* The background thread should do whatever is needed to prepare  the 
>>>PDF file, and set a flag variable in the user's session when it's 
>>>done,  followed by terminating the thread.
>>>
>>>* The "Please Wait" page should say something like "Report generation  
>>>in progress", and use a meta-refresh tag to automatically submit 
>>>itself  every few seconds, with the destination being a "Done Yet" 
>>>action.
>>>
>>>* The "Done Yet" action will consult the flag variable in the user's 
>>>session.
>>>If its not there, forward back to the "Please Wait" page again.  If 
>>>it's  done, forward to the URL to retrieve the PDF itself.
>>>
>>>Craig
>>>
>>>
>>>
>>>
>>>   
>>>
>>>      
>>>
>>>>My code is shown below....
>>>>
>>>>//the jsp code calling the action
>>>><nested:form action="/reports.do?action=getTransactionReports" 
>>>>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=\"images/dpt_logo.jpg\"></body></html>");
>>>>// 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_P
>>>>D
>>>>F)) return (new ActionForward(pdfFilePath, true));
>>>>
>>>>return (new ActionForward(csvFilePath, true)); }
>>>>
>>>>
>>>>Any help would be appreciated. Thanks.
>>>>---------------------------------------------------------------------
>>>>-
>>>>--
>>>>
>>>><http://www.digitalpaytech.com/>
>>>>
>>>>            
>>>>
>>>>Rizwan Merchant - Software Developer
>>>>4105 Grandview Highway, Burnaby, BC, V5C 6B4, Canada
>>>>Email:        [EMAIL PROTECTED] 
>>>><mailto:[EMAIL PROTECTED]>
>>>>Phone:       604-688-1959 x243   Fax: 604-687-4329    
>>>>Toll Free:    1-888-687-6822       
>>>>Website:    www.digitalpaytech.com <outbind://11/www.digitalpaytech.com>
>>>>
>>>>
>>>>
>>>>  
>>>>
>>>>     
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>   
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>> 
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to