• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About scope page in JSP page

 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I am confuse about useBean with scope page or default.
My understanding is if I have usebean, example
<jsp:useBean id="myid" class="myclass"/>
That statement make "myid" have scope page. I think that jsp container will create new instance in pageContext for that JSP page. And every request into that page will use the same that instance.
Is it true? Correct me if I am wrong...
regards
daniel
 
Ryan Bailey
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if I'm wrong but I believe the answer to your question is this:
If a bean with the name of myid is not created, then one will be instantiated (providing you have a default constructor for your bean class). After one is located or instantiated it will be put into pageContext (the default). I believe if you make another request to this page the bean will not be available and an new instance will be created. I believe pageContext refers to specifically that page. If you make another request then you go off of that page. If you want your bean to be available for multiple request then set the scope of the bean to either session or application. If set to application then it is available to not only that specific user session but exposed to the entire web application.
Hope I'm right and this helps,
Cheers
Ryan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic