I've been through the archives and I thought the "please wait page" thread was
the solution to my problem. However after spending some time with the examples
I still can't get my servlet to work.
All I want to do is query a DB, get some info, process it and return some
data to the user. This will work fine if the user is very specific in their
requests but if they don't narrow down the search then the serverlet will
timeout before the results are returned and processed.
If there is a "simple" and straight forward way to solve this problem I would
really love to hear it. I've been struggling with this for over a week and I'm
out of ideas. I thought about putting all the processing in a thread and
joining up with the thread when it was ready but I feel this is the completly
wrong approach for servlets.
I've included the sample I'm working with below. Its a slightly modified piece
of code from the example posted previously on this list. I have set the loop to
be really high to show that the server will timeout before the results are
returned.

########## timeout.java ##################
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class timeout extends HttpServlet {
    public void init(ServletConfig conf) throws ServletException  {
    }

    public void doGet(HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException {

 res.setContentType( "text/html" );
 HttpSession session = req.getSession( true );
 PrintWriter out = res.getWriter();

 if ( session.getValue( "waitPage" ) == null ) {
    session.putValue( "waitPage", Boolean.TRUE );
    out.println( "<html><head>" );
    out.println( "<title>Please Wait...</title>" );
    out.println( "<meta http-equiv=\"Refresh\" content=\"0\">" );
    out.println( "</head><body>" );        out.println( "<br><br><br>" );
    out.println( "<center><h1>Testing if server will timeout<br>" );
    out.println( "Please wait.</h1></center>" );
    out.close();
 }
 else {
    session.removeValue( "waitPage" );
    out.println( "<html><head><title>Timeout test</title></head>" );
    out.println( "<body>" );        out.println( "<h1>Finished</h1>" );
    for ( int i = 1000; i > 0; i-- ) {
         out.println( i + " " );
         try { Thread.sleep( 10000 ); } // Decrease value to stop timeout
            catch ( InterruptedException e ) {}  }
    out.println( "<h1>Server did not timeout</h1>" );
    out.println( "</body></html>" );        out.close();
 }
    }
}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to