'Wait please ...' page



It is a common task for servlets (JSP) developers. Suppose you have a very long calculation and need output some messages for users waiting your servlet's results. One solution described below deploys DHTML for solving this problem:

<html>
<head>
<style type="text/css">
    #waitpage { position: absolute; }
    #mainpage { position: absolute; visibility: hidden; }
</style>

<script language=\"JavaScript\">
function init ()
{
    if (document.layers)
    {
      document.waitpage.visibility = 'hide';
      document.mainpage.visibility = 'show';
    }
    else
    {
      if (document.all)
      {
        document.all.waitpage.style.visibility = 'hidden';
        document.all.mainpage.style.visibility = 'visible';
      }
    }
}
</script>
</head>

<body onLoad="init();">

  <DIV ID="waitpage">

  <!-- your message is here: -->
  <center><i> Wait please ... </i></center>

  </DIV>

  <!-- your very very long calculation is here -->
  <DIV ID="mainpage">
    <script language="JavaScript">
         location.href='http://your_host/servlet/your_servlet';
    </script>
  </DIV>

</body>
</html>

 © Coldbeans   Comments?

See also Other tips from Coldbeans.