• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp:useBean Topics

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<jsp:useBean id="school" scope="application" class="translator.MyTranslator"/>
instaed of class use type attribute
 
reply
    Bookmark Topic Watch Topic
  • New Topic