A little history. I would like make a request for a
servlet and have an interstitial page that displays some kind of "loading" message then redirects the user to the appropriate page when the "loading" is done. The code below is how I thought it would work but it does not seem to.
Why does the following not work? Anyone have any suggestions? In particuliar it appears that the first call to response.flushBuffer(); does not seem to work.
package brett.test.servlet;
/**
* <p>Title: InterStitchalPageLoading</p>
* <p>Description: A
test Servlet to get an interstitchal page to work</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
import java.io.PrintWriter;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
public class InterStitchalPageLoading extends HttpServlet
{
public InterStitchalPageLoading()
{
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
processRequest(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
processRequest(request,response);
}
void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
// get the request dispatcher for the first half of the interstitial page
request.getRequestDispatcher("/pageLoad/interstitial_first.jsp").include(request,response);
// flush the output so that the browser will see the HTML
response.flushBuffer();
// Suck up some time...
for(int i = 0; i < Integer.MAX_VALUE; ++i)
{
for(int j = 0; j < 10; ++j){}
}
// get the request dispatcher for the second half of the interstitial page
request.getRequestDispatcher("/pageLoad/interstitial_second.jsp").include(request,response);
// flush the output so that the browser will see the HTML
response.flushBuffer();
}
}
[ March 24, 2004: Message edited by: Brett Delia ]