Search code examples
jspjsp-tags

What is the different between the JSP syntax and XML syntax in .jsp?


I want to ask a question about the .jsp. What is the different between using the jsp syntax (e.g. <%! .. %>) and the XML syntax (e.g. <jsp:declaration>...</jsp:declaration>). Is there maintenance or some kind of advs by using one of the syntax? Thank you.


Solution

  • The "JSP syntax" allows scriptlets (java code) which is a bad practice.
    The JSP are meant to create pure presentation, so no need of heavy java in your page.

    When you put Java code in your JSP, it become harder to maintain and reuse, as your page doesn't simply display informations but can interact with your data.

    This is why the pure XML syntax is a such great idea. No more java in your JSP, if you need to do some treatments you can use differents taglibs and Expression Language to do simple operations (loops, etc.)


    Resources :

    On the same topic :