How should we use the label technology? JSP Example of complex background processing functions using the EL, logic, and hanva tag Libraries

Source: Internet
Author: User

Address
The JSTL tag is a product SUN has taken the lead in cooperating with the apache (the most popular WEB server platform on the Unix platform) community. Unfortunately, it has become an outdated technology since its appearance. SUN's software architects seem to lack the ability to consider the technical orientation from the customer's perspective, which is far behind Microsoft. As far as the tag technology is concerned, it aims to make cainiao in cainiao be able to write jsp (the first choice for SUN enterprise-level applications), or to make general programmers write jsp (the first choice for SUN enterprise-level applications) is it more convenient and better managed? Apparently, SUN's stupid architect didn't want to understand this truth (the more he reads the documentation, the more he thinks the guy is a big idiot ), the talents of SUN's thousands of talented engineers were wasted.

Everyone knows that jsp (the first choice for SUN Enterprise Applications) is designed to make it easier for programmers to write simple servlets, the complex multi-functional servlet implementation is not easy to use jsp (the preferred choice for SUN Enterprise applications. Jsp (the preferred choice for SUN enterprise-level applications) does not achieve the goal of writing java Dynamic Pages. This is not as good as ASP/PHP. Spreading the underlying business logic in jsp (the preferred choice for SUN Enterprise Applications) is neither convenient for Object Organization nor code management, which is very inefficient. This is the reason for the development of the javaBean and tag technology. In JSTL, the basic customer logic of JSTL is actually to help users more easily spread the underlying code in jsp (the first choice for SUN enterprise-level applications) up !? Including database connections ?! Therefore, this product is a new product that achieves the backward goal of technology, and it has slowed down in the face of market demand.

The only thing that has some value is its loop logic. This one is useful. Only one of them can be implemented, struts. logic labels are a good method, and do not point to http:/sun. in fact, JSTL can also provide struts: logic. In fact, several struts tag libraries are also logi, which is somewhat valuable. bean can also be used. Other html is provided by the MVC hypothetical framework with pure and FormBean as the core. Even so, in terms of practicality, strutslib is much more practical than sun.

The struts tag library is not very good at targeting data objects, which is its deficiency. The hanva tag is used to supplement this deficiency. Combined with the struts logic library, hanva labels can be used to declare and receive variables in jsp (the preferred choice for SUN Enterprise applications), and multiple logics can be implemented, you can directly obtain persistent non-foreign data objects from the underlying layer, and process and output the data objects. A program can only process these objects. Special things are processed in a special way. You can use tags to call the daemon program of the lower-level service to complete most functions.

The following Forum example deletes a program. It can be used to delete any table data that implements the hanvaDAO interface specification, including synchronizing related data records. It receives an object type (ent) and ID, determines whether the object (row record) exists, and then determines whether its sourceid and id are consistent (whether it is a primary post or a heel post ), if it is a primary post, delete it from the post. Otherwise, only the current post will be deleted and a page called will be returned. If an error occurs, it will be switched to errors. jsp (preferred for SUN Enterprise Applications) page, displays error information.

<Entity: present ent = "$ {param. ent}" oid = "$ {param. oid}" id = "thent" nexto = "$ {header. referer}">
<% -- If the record exists, the embedded logic is inherited and the record is set as the ident name -- %>
<% -- Determine whether sourcid and id are consistent -- %>
<Logic: equal name = "thent" value = "$ {thent. sourceid}" property = "id">
<% -- Take All Master/Slave stickers and name the set theobjs -- %>
<Entity: entities ent = "$ {param. ent}" id = "theobjs" qstr = "sourceid =$ {sourceid}">
<% -- Iterate the content of the set. A single name is named theobj -- %>
<Logic: iterate id = "theobj" name = "theobjs">
<% -- Delete this object -- %>
<Cmd: delete ent = "$ {param. ent}" target = "$ {theobj}"/>
</Logic: iterate>
</Entity: entities>
</Logic: equal>
<Logic: notEqual name = "thent" value = "$ {thent. sourceid}" property = "id">
<% -- A single slave sticker to clear this object -- %>
<Cmd: delete ent = "$ {param. ent}" target = "$ {thent}"/>
</Logic: notEqual>
</Entity: present>

When the Tag ends, the client switches to the caller according to nexto, so that the small Code actually plays the c Role in MVC. To output a breakpoint, you can call hanva: log to output real-time content to the log. A complicated function is complete. The whole process is actually only one or two accesses to the database. If there are multiple slave stickers, You need to obtain its strings. This is the second time possible. Note: The <entity: entities> label can be used to enter a condition or the fields option to obtain an ArrayList string (no Vector is required for synchronization). If it is not used to flip pages, it can replace hanva: list, which is more convenient to use. You do not need to set a dao first. list object.

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.