• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Page Beans

 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you use page beans as the model in the Model-view-controller architecture? If you have a servlet acting as the controller and it populates a bean that you want to use for dislay- say named displayBean, and the servlet forwards the request on to the display JSP, how can the JSP use the displayBean for the model as a bean? If the JSP uses the same bean with page scope, it will instantiate a new bean just for that page and not use the one from the servlet, right? I realize you could attach the bean to the request object and use request scope in the JSP, but the books I have say you should use a page bean for the model. How?
Thanks
Brian
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using a bean with only page scope for data that you want to forward does not make any sense. It should at least be request scope.
Which book is this and what is the rational for using page scope?
Bill
 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that's what I thought but I was confused by what I read. I was reading the Java Server Programming J2EE Edition from WROX. So really a page bean is only good if your JSP is using a bean and that bean does some processing to populate itself, then the JSP can call the getXXX methods of the bean to finish the display, right?
Thanks
Brian
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic