Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Beans and the MVC design pattern

 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going through the book: Core Servlets and JavaServer Pages and am a little confused about when I would use one specific feature. The book showed that I can automatically have my request parameters assigned to members of my Java Bean class, if I name the class members exactly the same as the request parameters, then use the following syntax in the JSP page:
However, in the MVC design pattern (as it relates to Servlets and JSPs) the JSP is never really going to read the request parameters. Instead, the servlet (acting as the controller) gets the initial request, processes the business logic, assigns all the appropriate values to a session (or whatever) bean, then forward to the JSP. The JSP (acting as the View) just displays the data from the session (or whatever) Bean.

As far as I can tell, there isn't any way to automatically assign all the request parameters to bean class members from with the Servlet code; you have to read each request parameter manually.

Am I missing something?

Thanks,
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, I missed the section in Chapter 4 of that book about BeanUtilties, which seems to cover this case.
I'll go back and read a little harder
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I use the Jakarta Commons BeanUtils class. It's wonderful.
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Bear. That seems to be what is exhibited in chapter 4 of the Core Servlets book.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic