aspose file tools*
The moose likes Servlets and the fly likes Page Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Page Beans" Watch "Page Beans" New topic
Author

Page Beans

Brian Nice
Ranch Hand

Joined: Nov 02, 2000
Posts: 195
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

Joined: Mar 22, 2000
Posts: 12806
    
    5
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

Joined: Nov 02, 2000
Posts: 195
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Page Beans