File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:useBean Topics

 
Michael Santosa
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • 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...
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
<jsp:useBean id="school" scope="application" class="translator.MyTranslator"/>
instaed of class use type attribute
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic