Hi,

You can also use a 100% applet approach. The principle is load excplicitly
the classes you need while displaying a message, and let every class loaded
notify the loading class.  For this, you will have to modifiy you classes,
adding constructors with an extra argument, which is the object to notify.
For example, class A is the loading applet. It will load class B the
following way :

B b = new b(parameter1, parameter2, ....., this);

(The reference this can be replaced by any reference to any object to be
notified.)

You must also add to the constructor of class B the code to notify the
object referenced by the last parameter.
That way, applet A will know when class B will have been fully loaded. This
might not allow you to display exact percentages, but it may be sufficient.

But better than displaying the percentage loaded is to preload the classes
while the users is navigating through other pages. This can be done very
easily through an applet with no display. This applet can be put on any (or
all !) pages and only need a init method such as this :

public void init() {
        Class classToLoad = B.class;
        classToLoad = C.class;
        // etc...
}

This way, if the user as some text to read before reaching the applet, the
needed classes will have been already loaded an stored in cache.

Pierre-Yves

-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet API
Technology. [mailto:[EMAIL PROTECTED]]De la part de Mark
Galbreath
Envoye : dimanche 8 juillet 2001 17:41
A : [EMAIL PROTECTED]
Objet : Re: How I can make my applet show something when loading instead of
gray background?


That's exactly what I'm trying to tell you.  Have another, simple applet
load before your chat applet that simply displays "5% complete...," "10%
complete...," etc.  as values calculated by the servlet and passed to the
utility applet using a persistent connection.  You can calculate these
percentages as an ongoing ratio of Content-Length to bytes sent through the
OutputStream that's sending your chat applet.  You could also display the
progress as a graphic using Swing (like Flash can do), but I think you want
to keep the footprint as small as possible.

Alternatively, you could use Flash.  It has a very small footprint and there
has been much discussion on this list regarding servlet-Flash
intercommunication (see archives).

Hope this helps....

Cheers!
Mark

----- Original Message -----
From: "Victor Gratchev" <[EMAIL PROTECTED]>
Sent: Saturday, July 07, 2001 6:15 PM


You must be not correctly understand me. I have chat wrote as applet.
But he is 40K byte length and on slow connection loading about 30
seconds and people see gray rectangle and think that it's error and
close window with applet they don't know that applet is loading... Can I
read some variable or something what show state of loading and show the
percent of loading in process of loading applet?

-----Original Message-----
From: Mark Galbreath [mailto:[EMAIL PROTECTED]]
Sent: Saturday, July 07, 2001 2:52 AM

Yes.  Most servers internally manage the Content-Length header for the
static files they serve; the Content-Length is set to match the file's
length.  To determine the content length of servlet-generated output, a
server requires the servlet's assistance.  A servlet can set the
response
Content-Length and gain the advantages of a persistent connection for
its
dynamic content by using the setContentLength() method of

public void ServletResponse.setContentLength( int len)

This method sets the length (in bytes) of the content being returned by
the
server.  In an HTTP servlet, the method sets the HTTP Content-Length
header.
Using this will allow your servlets to be able to take advantage of
persistent connections when they are available.  Your applet will be
able to
display an accurate progress monitor during the download.

----- Original Message -----
From: "Victor Gratchev" <[EMAIL PROTECTED]>
Sent: Friday, July 06, 2001 5:30 AM

Can I make my applet show percents of loaded like flash?

___________________________________________________________________________
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

___________________________________________________________________________
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