Link to home
Start Free TrialLog in
Avatar of phillipsweeeney
phillipsweeeney

asked on

how to show some status on a jsp while processing?

I have a jsp that initiates a long running background process.

I need to send the user some feedback during the processing time and at the same time prevent the session from timing out.

Does anyone have some details (sample code) on how this can be done?  currently the user just sits and waits with no status on the screen...which is bad.  At the end of processing there is an sql result that needs to be displayed on the screen.

Thanks a lot - in advance.

PS
Avatar of Mick Barry
Mick Barry
Flag of Australia image

simply kick off your processing and immediately return a 'processing' page, maybe with an auto refresh.
If the page is again requested while processing is still in process then return details about state of processing.
Avatar of phillipsweeeney
phillipsweeeney

ASKER

The process starts when the user clicks a button on an html form pointing at the jsp with the call to the process.

The users browser stays on the original jsp (with the form button) while the the target jsp runs the process.

So i don't know what you mean when you say "return a processing page"?  

How do i return a "temporary" JSP page while the calling form points to the jsp with the long running process?



Here's what I do:  in the called JSP, BEFORE you actually call your long running process, do some out.print stuff saying "please wait" or whatever.

Then call out.flush() ... then start your process.

the flush will cause the user to see at least that message right away.  You might also periodically do

out.print(".");
out.flush();

DURING the process so they can see movement.

ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Here is what i did - - -created new backround thread, so jsp continues
//********************************JSP code calling new thread**************
Runnable crfthread = new CRFThread(crfparser, crftools);  


//*******************new thread code********************
public class CRFThread implements Runnable
{


CRFParser crf;
CRFTools crftools;

public CRFThread(){
          Thread t = new Thread(this);
          t.start();
}  // end constructor method

public CRFThread(CRFParser _crf, CRFTools _crftools){
          crf = _crf;
          crftools = _crftools;

          Thread t = new Thread(this);
          t.start();
}  // end constructor method

public void setCRFParser(CRFParser _crf) { crf = _crf; }
public void setCRFTools(CRFTools _crftools) { crftools = _crftools; }

public void run() {
                          try {

                                   boolean validateuser = crftools.validateOSAUser(crftools.userName, crftools.userPassword);
                                   String s = crftools.writeCRF(crf); // all background stuff happens here - jsp continues
                                   
                                   
//*********Blah Blah*************************