Place the business logic in Java Beans?

Posted by Lirik on Stack Overflow See other posts from Stack Overflow or by Lirik
Published on 2010-03-22T02:07:59Z Indexed on 2010/03/22 2:11 UTC
Read the original article Hit count: 453

Filed under:
|
|
|
|

I was reading this page and I found the following statement:

MVC in Java Server Pages

Now that we have a convenient architucture to separate the view, how can we leverage that? Java Server Pages (JSP) becomes more interesting because the HTML content can be separated from the Java business objects. JSP can also make use of Java Beans. The business logic could be placed inside Java Beans. If the design is architected correctly, a Web Designer could work with HTML on the JSP site without interfering with the Java developer.

Interestingly in my textbook I pulled the following quote:

In the MVC architecture... the original request is always handled by a servlet. The servlet invokes the business logic and data access code and creates beans to represent the results (that’s the model). Then, the servlet decides which Java Server Page is appropriate to present those particular results and forwards the request there (the JSP is the view). The servlet decides what business logic code applies and which JSP should present the results (the servlet is the controller).

The two statements seem slightly contradicting. What is the best way to use beans: should we place business logic in them or should we only place results in them? Are there ways in which beans are inadequate for representing a model?

© Stack Overflow or respective owner

Related posts about beginner

Related posts about javabeans