• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Interstitial Page loading woes

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Redirection in JSP is done using an HTTP response header. To display an initial page, then redirect later, you would have to use some sort of "http-equiv" HTML meta value, or write some JavaScript into your response that would redirect the client's browser to retrieve the next page (portion) or your response.
If that's what your second page is doing, I'm not sure what the problem is. Maybe the browser is for some reason waiting until the entire response comes through before it displays anything. (I have no clue, sorry.)
 
Brett Delia
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about not posting the JSP's. Here they are.
First half of the page that get sent first...

Second half of the sent page after processing is done:

And finally the results page:
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we do the same sort of thing with some of our pages, but we push the whole page out...

I know.. sloppy html'ing !


Now basically, the page immediately goes to the 2nd page, but the browser (at least the ones that we've ever tested with) will not clear the existing page, until the page it is next requesting starts to come in. (or sometimes until that next page is completed rendering, but don't count on that!).
This leaves you with the effect of the 'wait' page displaying, until the next page is ready to show.

Seems to work for us. Might not work so well if you have lots and lots of "extra_params=here" sort of stuff.
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic