When I put this line at my
JSP page :
<jsp:useBean id="school" scope="application" class="translator.MyTranslator"/>
Then it will compile it into
servlet like this
using
TOMCAT :
translator.MyTranslator school = null;
boolean _jspx_specialschool = false;
synchronized (application)
{
school= (translator.MyTranslator)
pageContext.getAttribute("school",PageContext.APPLICATION_SCOPE);
if ( school == null )
{
_jspx_specialschool = true;
try
{
school = (translator.MyTranslator) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "translator.MyTranslator");
}
catch (ClassNotFoundException exc)
{
throw new InstantiationException (exc.getMessage());
}
catch (Exception exc)
{
throw new ServletException (" Cannot create bean of class "+"translator.MyTranslator", exc);
}
pageContext.setAttribute("school", school, PageContext.APPLICATION_SCOPE);
}
}
It means the school bean is always act
as "local variable".. whatever its scope
is.
So when I want to use this instance of
bean again in another JSP page,
then I put the same code
<jsp:useBean id="school" scope="application" class="translator.MyTranslator"/>
Then I will get the same instance, right ?
Please correct me if I am wrong...