Java Web Development Fundamentals (3)-jstl

Source: Internet
Author: User

The JSTL tag Library was exposed to the DRP project, and the first sensation was "stunning" for a lazy person like me.

Jstl the use of tag libraries. Can eliminate a lot of complex and complicated work. The workload is less than 1:30 o '. is to reduce the more than half. No matter what the introduction of the tool, it will make our work simple. But the problem is that our work can be easy, but we can't make our brains simple. So, we are not simply able to use it. We also need to know how this tool works. How to provide convenience for us. Ok. Let's get to the point where we start ...

problems with JSP scriptsI don't know, what do you think about seeing these few children? Anyway, I think JSP is like Sun Monkey Mana is boundless but not obey the discipline. It's a headache. Why is it? JSP scripting greatly improves the complexity of the program, and at the same time JSP scripts add code reading difficulties. Finally, and the most vexing problem is debugging trouble (feeling deep).

This is the source. If you think you're not deep enough, you can try to write your own JSP script.
From JSP1.1, JSP supports using its own definition tag in JSP to solve the problem of JSP script. However, the widespread use of their own definition of labels has led to new problems, namely, repeated definition, poor reusability. So. Sun has introduced the label standards, namely JSTL (JSP standard tag Libaray), and Apach implements the JSTL specification.

The following prices Jstl ...

JSTL Brief IntroductionJstl contains five types of standard tag libraries: Core library, format library, XML Library, SQL Library, function library. For example, as seen in:
  

Jstl actually with a good interface or interface to replace the JSP script work, we know that the JSP page will be parsed into a servlet, so webservlet container in the introduction of JSTL must have a corresponding parser. And then. It's no different from the original JSP script. This means that the work done by Jstl is an optimization.
In addition, JSTL and El expressions are used in a piece. But El expressions are not part of the JSTL.

Because, in the absence of Jstl, the El expression is also able to be used. Although some data directly say that Jstl contains the two parts of Jstl and El expressions, it should be inappropriate.

So. The EL expression is described separately in the next blog post.

Instance Experience

This is the loop output that is done using JSP scripts and Jstl.

jsp version number:
         
            <%list itemList = Pagemodel.getlist (); for (Iterator iter = Itemlist.iterator (); Iter.hasnext ();) {Item item = (item) iter.next ();    %><tr>    <td class= "Rd8" ><input type= "checkbox" Name= "Selectflag" class= "CheckBox1" value= "< %=item.getitemno ()%> ">    </td>    <td class=" Rd8 "><a href=" "onclick=" window.open (' Item_ Detail.html ', ' Specific information ', ' width=400, height=400, Scrollbars=no '); ><%=item.getitemno ()%></a>    </td>    <td class= "Rd8" > <%=item.getitemname ()% >    </td>    <td class= "Rd8" >  <%=item.getspec ()%>    </td>    <TD class = "Rd8" >          <%=item.getpattern ()%>    </td>    <td class= "Rd8" >  <%= Item.getitemcategory (). GetName ()%>    </td>    <td class= "Rd8" >  <%=item.getitemunit ( ). GetName ()%>    </td></tr><%}%>

jstl version number:         

            <c:foreach items= "${pagemodel.list}" var= "item" >           <tr><td class= "Rd8" ><input type= " CheckBox "Name=" Selectflag "class=" CheckBox1 "value=" ${item.itemno} "></td><td class=" Rd8 "><a href = "#" onclick= "window.open (' item_detail.html ', ' material specific information ', ' width=400, height=400, Scrollbars=no ');" >${item.itemno}</a></td><td class= "Rd8" >${item.itemname}</td><td class= "Rd8" >${ Item.spec}</td><td class= "Rd8" >${item.pattern}</td><td class= "Rd8" >${ Item.itemCategory.name}</td><td class= "Rd8" >${item.itemunit.name}</td></tr></c: Foreach>



Summary : overall. The biggest feature of JSTL is simplicity. It is equivalent to a JSP script to do a package, or the appearance of the application of the pattern. The complex logic processing is hidden, providing a unified interface to the outside. In other words, the development of JSP page can not rely on Java code, that is, the more the division of labor, the more a single development trend for the web development of the reality and logic to draw a line. This means that the developer's configuration to realize the understanding of decoupling and.

                         

Java Web Development Fundamentals (3)-jstl

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.