JSTL: What's the point?

I have been doing JSPs for many years, doing all of my work in classes and using the minimal amount of Java code in JSP to get results, and sometimes to conditionally render content.

I am looking to steal my game and I was looking at using / learning more JSTL.

My big questions - why bother? What is the meaning of JSTL tags?

For example, there are tags for database queries on the JSP that IMHO violate the law of the haloed MVC separation principle.

I see no benefit to using a tag for a conditional or just putting code for a conditional expression in

<% ... %> 

Maybe if this is a large website with a dedicated web designer who feels less intimidated by tags?

As for iterations, I prefer to do this in the β€œview” class and just pull the complete line in the JSP between static HTML tags (for example, pulling table rows from a class in JSP between table tags in JSP that are connected to CSS).

I do not want to seem disrespectful or ignorant. I am curious. What is the advantage of using JSTL?

+4
source share
2 answers

Because it's easier and faster to do something like

 <fmt:message key="translation.key"/> 

instead of loading ResourceBundles each time manually.

And you can use custom tags like

 <mytags:security hasRole="ADMIN"> content for the admin <mytags:customButton key="value"/> </mytags:security> 

You do not need the "view" class. JSP is a "view"

+2
source

doing all my work in classes

I believe this was an idea (good or bad) JSTL: to enable people who are responsible for the level of presentation to do something quickly / easily, without delving into the server side.

0
source

Source: https://habr.com/ru/post/1401604/


All Articles