Hi Alan,

> What initialisation is your servlet doing?? 

The servlet itself is attaching to MySQL, and doing a quick
query. 

If I access the servlet directly, (no jsp) there is _no_ delay
whatsoever.  The MySQL connection, query, formatting all take
less than a tenth of a second even on the very first access
after Tomcat has started.

I'm not creating any sessions yet, so the randomizing of the
session ID isn't the cause of the problem...

This is the last problem I have before I start doing some
deployment!  Now that I've spent the time to get to know Tomcat,
I'm loving it.

During Initialization:

- the Servlet checks the context for an existing Database Engine
and then (when it doesn't find one) instantiating one and 
adding it to the servlet context:

        // make sure that the VSDBEngine is running
        ServletContext context = getServletContext();
        if (null == (itsEngine =
(VSDBEngine)context.getAttribute("vsdbEngine")))
        {
            itsEngine = new VSDBEngine(context);
            context.setAttribute("vsdbEngine", itsEngine);
        }

- It initializes a database Connection Pool, and a JDBC Table-oriented
helper class.

    public VSDBEngine(ServletContext sc)
    {
        // necessary for logging
        itsServletContext = sc;

        log("------------------ ( r e ) l o a d  --------------------");

        // load a database driver that the driver manager
        try
        {
            // The newInstance() call is a work around for some
            // broken Java implementations
            Class.forName("org.gjt.mm.mysql.Driver").newInstance();
        }
        catch (Exception e)
        {
            log("Unable to load driver.");
            e.printStackTrace();
        }

        // should work with Tomcat... databaseURL is defined in the
web.xml file.
        String dbURL =
config.getServletContext().getInitParameter("databaseURL");

        // initialize the Connection Pool
        String dbURL = (String)sc.getInitParameter("databaseURL");
        itsConnectionPool = new VSDBPool(dbURL);
        itsConnectionPool.sc = sc;

        itsTableJDBC = new TableBasicJDBC();
        itsTableJDBC.setContext(sc);
        itsTableJDBC.setPool(itsConnectionPool);
    }

- It does a query
            // set content type and other response header fields first
            statement = c.createStatement();

            sql = "SELECT slideID FROM slide";
            sql += " WHERE";
            sql += " favorite='yes' ";

            statement.execute(sql);
            result = statement.getResultSet();

            while (result.next())
            {
                ids.addElement(new Long(result.getLong("slideID")));
            }

- then prints results.

-James Carroll
--------------------
MicroBrightField Inc. 

> -----Original Message-----
> From: Alan Stenhouse
> [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 22, 2001 10:43 AM
> To: [EMAIL PROTECTED]
> Subject: AW: Delay (40 seconds) on first jsp access
> 
> 
> 
> 
> > 
> > Delay (40 seconds) on first jsp access
> > 
> > Hi,  On Windows 98, Tomcat 3.2.1 & 3.3M2 (they both show the delay)
> > Stand-alone...   I have some Servlets, that I include into some
> > pages like so:
> > ...
> > <h2>Favorite Public Virtual Slides</h2>
> > <jsp:include page="servlet/GroupFavorites" flush="true" />
> > ...
> > 
> > Q: Is there any better way to include the output from a servlet
> > in an otherwise static page?
> > 
> > The very first time I start Tomcat, and access this page, there
> > is a very very long delay.  Everything is running on localhost,
> > so I don't think there is any kind of name lookup that is timing
> > out...
> > 
> > If I turn on LogEvents in 3.3M2, I get the following:
> > 
> > .......
> > 2001-03-22 10:33:47 - LogEvents: preServletInit 
> > DEFAULT:/mbfvs ServletH
> > TOMCAT/J
> > SP/intro.jsp(SW (/intro.jsp CN=intro_1))
> > 2001-03-22 10:33:47 - LogEvents: postServletInit 
> > DEFAULT:/mbfvs ServletH
> > TOMCAT/
> > JSP/intro.jsp(SW (/intro.jsp CN=intro_1))
> > 2001-03-22 10:33:47 - LogEvents: preService R( /mbfvs + /intro.jsp +
> > null)
> > 
> > Long delay
> > 
> > 2001-03-22 10:34:21 - LogEvents: postService R( /mbfvs + 
> /intro.jsp +
> > null)
> > 2001-03-22 10:34:21 - LogEvents: postService R( /mbfvs + 
> /intro.jsp +
> > null)
> > 2001-03-22 10:34:21 - LogEvents: beforeCommit R( /mbfvs + 
> /intro.jsp +
> > null)
> > 2001-03-22 10:34:21 - LogEvents: afterBody R( /mbfvs + /intro.jsp +
> > null)
> > 2001-03-22 10:34:21 - LogEvents: postRequest R( /mbfvs + 
> /intro.jsp +
> > null)
> > ........
> > 
> > The delay is _much_ longer than it would take to compile 
> the jsp page,
> > and there is no hard drive activity during the time.
> > 
> > Does anyone have any idea what would be stalling at this point???
> > 
> > Thanks!!!
> > -James Carroll
> > --------------------
> > MicroBrightField Inc. 
> > 
> 

Reply via email to