> <%
>
[quoted text clipped - 15 lines]
>
> %>
> Boolean hasMail has to be declared outside of the thread because it's
> used there. How on earth do you make hasMail final within JSP? That's
> got to be impossible to do!
It's actually quite possible, except that you want to change the value of the
boolean.
Remember, scriptlet (which you should avoid - separate conversation) is just
code inserted into the service() method of the resulting servlet.
I will assume that the variable 'mar' is used after the thread join(),
otherwise you could declare it inside the Runnable run() method.
Simply add the 'final' decoration to your variable declaration:
final MailAdminReader mar = new MailAdminReader();
Unfortunately, since you want to change the value of the boolean, that won't
work for the boolean. It will work for a spontaneous holder class, though:
<%
final MailAdminReader mar = new MailAdminReader();
class Result
{
public boolean hasMail; // initialized automatically
}
final Result result = new Result();
Thread t = new Thread( new Runnable ()
{
public void run()
{
try
{
result.hasMail = mar.checkForMail();
}
catch ( Exception ignore )
{}
}
}
);
// etc.
%>

Signature
Lew
Lew - 03 Mar 2008 16:12 GMT
> <%
> final MailAdminReader mar = new MailAdminReader();
> class Result
> {
// oops! forgot to say
volatile
> public boolean hasMail; // initialized automatically
> }
[quoted text clipped - 17 lines]
> // etc.
> %>

Signature
Lew