JSP Example for the tag library to complete complex background processing functions

Source: Internet
Author: User

The JSTL tag is a product that SUN takes the lead in working with the apache 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. In terms of tag technology, it aims to enable cainiao to write JSP, or make it easier and better for programmers to write JSP? 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 the purpose of JSP is to make it easier for programmers to write simple servlets. The implementation of complicated and versatile servlets is not easy to use. JSP does not achieve the goal of letting cainiao write java Dynamic Pages. This is not as good as ASP/PHP. Spreading underlying business logic in JSP 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, its basic customer logic is actually to help users more easily spread the underlying code on JSP !? 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 logic library of struts, hanva labels can be used to declare and receive variables in jsp. Multiple logics can be implemented and persistent non-foreign data objects can be directly obtained from the underlying layer, process and output-a program can only do these things. 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 page that 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.

I think this is the true use of the label technology: it helps programmers clearly and clearly call the background processing program on the interface, and establishes the business logic of the instant noodles to the object, so as to conveniently hide the logic of the non-expression layer; instead of a new method that makes pages more complex and makes code more difficult to understand.

Comparatively speaking, the tags file tag technology is more realistic. Just as jsp is a simple servlet for cainiao (still a programmer), the tags Tag file is a cainiao that is easy to see and trembling with Class, and writes tags like jspjavalet. Obviously, is the simplest SimpleTagSupport variant. Only the SimpleTagSupport has its own content. Similarly, the coding technology that makes full use of the Class structure cannot be implemented here.

The JSP development community seems keen to provide some local convenience measures in a local style, but often ignores the customer's bigger requirement: to use a single standard paradigm to complete all programs in project development as much as possible. It is easy to use a small technical mode, but it is a kind of technology for managing the whole, or a programmer needs to learn a technology that is only effective locally. This logic error has been accompanied by SUNJAVA's technological development since J2EE. It seems to be an incurable disease. In the opinion of the author, it is better to drill down at the core to the end with more minor actions. In a small range of convenient measures, it is better for competent customers to achieve. Poor imitation of Microsoft's lagging behind (also non-mainstream customers) will be the final technical failure of SUN.

Related Article

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.