Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why business logic should be moved out of JSP?

What are the advantages of keeping the business logic outside JSP, since JSP's are meant mainly for presentation? We still see business logic written inside the JSP, so I needed to know what benefit we get by moving business logic out of JSP.

like image 583
nithin Avatar asked Apr 28 '11 11:04

nithin


People also ask

Can JSP perform both presentation and business logic?

JSP can be easily managed because we can easily separate our business logic with presentation logic. In Servlet technology, we mix our business logic with the presentation logic.

How can I attach business logic with JSP page?

I suggest you to use a MVC patter to add the business logic to your web application on Java classes instead of add the logic into the JSP. Thanks. BTW this is a spring tutorial. With dependency injection and so on yo can simply access the HTTPServlet objects implicitly.

What is business logic and presentation logic in JSP?

In short, "business logic" is what rules the company has, while "presentation logic" is how the details are shown to users.

How does Java improve business logic?

4. For larger web applications the best approach is to keep minimal amount of code in each layer and a seperate layer is added centered around the business logic. This layer is termed as a business logic layer. For smaller applications the database objects itself could contain the business logic.


1 Answers

The main benefit of MVC is you can have multiple view and clean and separated architecture & Simplicity


Re usability

Suppose tomorrow you need same app running on a desktop app. then you can just change the view.


Testability

You can unit test your service methods, but you can't simply unit test logic from view.


Maintainability

It is easy to understand the code from Service methods, also we can change it /release service api and maintain it easily


Version ability

You can give version to your API and maintain standard docs related to issues/updates if you use service API instead view for logic


See Also

  • Understanding MVC
  • What is MVC ?
  • Separation Of Concern
like image 181
jmj Avatar answered Oct 19 '22 05:10

jmj