ok Amit,

I have a class that's called XLReport implementing runnable.
and that's generating a report to a file on the system.

I have a report servlet that's doing the following :


//1. builds a random filename where the final report will be copied
String reportName=
this.cenProps.getProperty("webrootpath")+"/reports/"+login+(new
Date()).getTime() ;

//2. creates a XLReport object
        XLReport threadedReport = new XLReport();
//3. set various params
        threadedReport.setLogin(login) ;
        threadedReport.setCriteriaQuery(criteriaQuery) ;
//4. set the target filename
        threadedReport.setReportName(reportName) ;
//5. starts the generating
        threadedReport.generate() ;
//6. redirect to the jsp (waiting.jsp) that will monitor the existence of
the file every 30 secs

res.sendRedirect("/cen/"+User.language(login)+"/waiting.jsp?target="+reportN
ame+".csv");

//7.finaly registers the report object seomewhere (in session) where it's
not going to be destroyed, there
//is probably a better solution, but that one works, unless the same user
genetares several reports,
//but in this case this system needs more modifications.

        session.setAttribute("reporter",threadedReport);

The XLReport  is not doing much :

public class XLReport implements Runnable {

//properties
private String criteriaQuery;
private String login;
private String reportName= null;
//setters
public void setCriteriaQuery( String value){
  this.criteriaQuery=value;
  }
public void setLogin( String value){
  this.login=value;
  }
public void setReportName( String value){
  this.reportName =value;
  }

/**
 * empty constructor, does nothing
 */
    public XLReport() {
    }
/**
 * main method to be called after setting the values,
 * creates and starts the thread.
 */
    public void generate(){
      Thread myThread = new Thread(this);
      myThread.start() ;
    }
/**
 * run method, generate the report in a temporary file and rename it when
finished,
 * this is used in conjunction with another jsp or servlet to monitor if the
report
 * is done or not.
 */
public void run(){

          //rename file

          tempFile.renameTo(targetFile);
          tempFile=null;
          targetFile=null;
  }

}

Philippe Bertramo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[EMAIL PROTECTED]
5, rue d'Oradour L-2266 Luxembourg
Tel : +352 26458782
GSM : +352091461365
http://www.waex.com

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.385 / Virus Database: 217 - Release Date: 04/09/2002

______________________________________________________________________
Get the JRun Web Application Construction Kit - the only book written specifically for 
JRun developers.
http://www.amazon.com/exec/obidos/ASIN/0789726009/houseoffusion
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to