Monday, February 27, 2006

Re: JSTL - What's the point?

What is the logic behind separating presentation from code? Apart from the "MVC pattern"/"loosely coupled principle", it is also to accommodate designers and coders....The "logic" is still ingrained within the presentation. It is still code, just with tags, instead of java. How is this any better for designers or code maintenance? Somehow this made no sense to me.

What you mentioned is very right. See this post section Using the SQL Actions

The JSTL includes a number of actions that provide a mechanism for interacting with databases. The previous sentence should, at a very minimum, send up a red flag in your architectural visions. One might ask, "Do I really want to be able to perform SQL actions such as queries, updates, and transactions from my JSP? Isn't that business logic that belongs in the model?" The answer is yes. Yes, yes, yes. To follow a Model-View-Controller (MVC) architecture, which is the predominant design pattern used in building web applications today, you definitely want to keep your model information in your business logic. This means that you don't want it in your JSPs. Why then are these actions even provided in the JSTL? Good question and one that I've discussed with various members of the JSR-53 expert group. The reason is the "C" or community in the Java Community Process (JCP). The community has asked for it, the community has gotten it.

So thats that. Even the tags Mohnish mentioned are not that great. But... its fine.

Adding to the comment ; JSTL was a another step. Jsp did something better than Servlets. Jstl added something. Then Jstl EL was added which was purposefully given a more JavaScript like syntax. Now we have JSF which gives a more component based web dev feel. I don't know much on JSF though. Also there are actually competing web frameworks in the Java world like Struts, Tapestry... So again loads of choice :)

ASP.NET has the right solution for separation with web controls.

Could you post or link a simple ASP.NET example showing this separation of UI/model?

How is webapp dev in php? Do they too generally look out for such MVC stuff?

No comments: