To display waitscreen (Excel export window pops up)

I am trying to put a waitscreen on submit.Once the form is submitted , it queries the database and responds back with a poup to export excel data(downloadaction).There is no way for me to figure out when the download action pops up.How do I do this ?

Below are the sample files I am dealing with.

JSP (I should display waitscreen once I click the CSV button).
<html:form action="/goJobContactReport" target="_blank" onsubmit="return (validateJobContactReportForm(this));">
<input name="reportName" value="<c:out value="${param.reportName}" />" type="hidden" />
<tr><td><html:submit styleClass="admin" value="CSV"
       onclick="multiSelectAll();return validateJobForm(new Array(contactTypeVal));" />
   <td class="vertalign" width=820 align=center>
   <h2 style="margin-bottom: 0px">
  <c:out value="${param.reportName}" />
<table> JSP with 5-6 fields.
 FIrst name:
Last Name :

ACTION extends myaction

public class JobContactReportAction extends myAction {
      private static org.apache.log4j.Logger logger = org.apache.log4j.Logger

      protected void setupReport(HttpServletRequest request, ActionForm form) {
  "JobContactReport Setup is called");

            sleepAttribute = "jobContactReport";
            //            CSV NAMES
            reportHeader = "CONTACTTYPE CODE ,NAME ,ADDRESS ,CITY ," +
             JOB CURR DOLLARS";
            reportColTypes = new String[] { "string", "string", "string", "string",
                        "string", "string", "string", "string", "date", "string",
            //            DATABASE NAMES
            reportColNames = new String[] { "CONTACTTYPE_CODE","NAME","ADDRESS","CITY","STATE","ZIP","CUSTNUM", "CUSTNAME",
reportTitle = reportDelimiter+reportDelimiter+reportDelimiter+reportDelimiter+request.getParameter("reportName");
reportSql = buildSQL((JobContactReportForm) form,isJobAddress);
private String buildSQL(JobContactReportForm form,boolean isJobAddress) {
            logger.debug("contact="+form.getContactType()+ "firstname="+form.getFirstName()+"lastname="+form.getLastName()
+"address="+ form.getContactOrJobaddress()+"city="+form.getCity()+"state="+form.getState()+
String colList = buildSelectCols(reportColNames, reportColTypes);
StringBuffer sqlselect = new StringBuffer("SELECT " + colList);
sqlselect.append(" FROM CONT_MVW ");
sqlselect.append(" WHERE  rownum<30000 "  );
String sql = sqlselect.toString();
return sql;

myaction extends downloadaction
public abstract class myAction extends DownloadAction {
private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(myAction.class);
// setup via setupReport()
      protected String reportSql;
      protected String[] reportColNames;
      protected String[] reportColTypes;
      protected String reportHeader;
      protected String reportTitle;
      protected String sleepAttribute = "";
      protected String reportDelimiter = ",";      
      private String _reportFileName;
      private File _reportFile;
      protected abstract void setupReport(HttpServletRequest request, ActionForm form);
      protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response) {setupReport(request, form);
            ServletContext application = getServlet().getServletContext();
            if ("".equals(sleepAttribute)) {
  "sleepAttribute is empty");
            try {
                  // For a specific report, try to run one report at a time.
                  // sleep if there is report running.            
                  int i=0;
                  while (application.getAttribute(sleepAttribute) != null) {
                        Thread.sleep(1000); // 1 second
                  application.setAttribute(sleepAttribute, "true");
                  logger.debug("sleep " + i);
                  logger.debug("set sleepAttribute " + sleepAttribute +
                                  " for session " +request.getSession().getId().substring(0, 9));
// file name is the first 10 chars of sessionid
_reportFileName = String.valueOf(Math.random()) + ".csv";
_reportFile = new File(servlet.getServletContext().getRealPath("/WEB-INF/reports/" + _reportFileName));
response.setHeader("Content-disposition", "attachment; filename=" + _reportFileName);
 ReportsDao reportsdao = new ReportsDao();
 reportsdao.createReportFile(reportSql, reportDelimiter, reportColNames, reportHeader, reportTitle, _reportFile);
catch (InterruptedException e) {
logger.error("CPRReportAction sleep fail.");
logger.debug("remove sleepAttribute " + sleepAttribute + " for session " +request.getSession().getId().substring(0, 9));
  return new FileStreamInfo("text/csv", _reportFile);
protected String buildSelectCols(String[] colNames, String[] colTypes)
StringBuffer colsbuf = new StringBuffer();
if (colNames != null){
int noCols = colNames.length;
for (int i=0; i<noCols; i++){
String tmp = colNames[i];
// For non-String type, convert to String
if (colTypes[i].equalsIgnoreCase("date")){
/* Replace 'table.field' with 'field' when naming the field in ORACLE */
tmp = "to_char(" + colNames[i] + ", 'mm/dd/yyyy') " +
colNames[i].replaceAll(colNames[i].substring(0, colNames[i].indexOf('.')+1), "");
            if(colTypes[i].equalsIgnoreCase("timestampHH24MM")) {
/* Replace 'table.field' with 'field' when naming the field in ORACLE */
tmp = "to_char(" + colNames[i] + ", 'mm/dd/yyyy HH24:mi') " +
colNames[i].replaceAll(colNames[i].substring(0, colNames[i].indexOf('.')+1), "");
      if (i==noCols - 1){
      } else {
colsbuf.append(tmp + ",");
                  return colsbuf.toString();
            } else {
        "colNames is null");
                  return "";

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pravin AsarPrincipal Systems EngineerCommented:
Here is a sample for you that a show how it could be done.

1. When a form is submitted, open a window with a name.
    At the time of opening this window, specify the  your waiting message(s).
2. Use that window's name as target window.
<title>Submit Form to a Target Window</title>
<script language=javascript>
var sw;
function OpenCenWindow (winname, width, height) {
  var x = 0.5 *(window.screen.width - width);
  var y = 0.5 *(window.screen.height - height);
  var posStr = ", screenX=" + x + ", screenY=" + y;
  if (typeof (sw) != 'undefined')  {
  if (document.all) {
		 posStr = ", left=" + x + ", top=" + y;
  var pStr = 'resizable, status=no,width=' + width + ', height=' + height + 
             ', alwaysRaised=1, addressbar=no, titlebar=no, toolbar=no, menubar=no, status=no';
  var sw = ('', winname,pStr +posStr );
  // Waiting Message
  sw.document.body.innerHTML = "Loading ...";
  return true;
<form target="ExcelWindow" onsubmit="return OpenCenWindow('ExcelWindow', 400, 400);">
<br>Name:<input type="text" name="fname">
<br>Email:<input type="text" name="email">
<br><input type="submit" value="Submit" onclick="this.disabled=true;">

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.