In the traditional jsp (preferred for SUN enterprise-level applications) program, HTML code and Java code are compiled together. This is convenient, but it also makes the page difficult to maintain, HTML developers and jsp (the preferred choice for SUN enterprise-level applications) developers are becoming more burdened. We can turn this traditional technology into page pulling data technology.
How can we separate HTML development from jsp (the preferred choice for SUN Enterprise Applications) development? The answer is to use the Tag technology. By using the Tag technology, we can avoid jsp (the preferred choice for SUN Enterprise Applications) code in the page program. Where data is needed, you should first agree on the tags, and then replace these tags with the Tag's background handler to display data. I call this technology push data to pages. You only need to define the format of the page. In this way, HTML developers can focus on the appearance of the page, while Java programmers ignore page display and focus on background programs, greatly improving the maintainability and convenience of the program. It facilitates collaborative development between programmers.
First, you must understand some Tag technologies before you can read this article. The following is an example program:
I. replace functions that replace strings
// Replace string functions
// String strSource-source String
// String strFrom-substring to be replaced
// String strTo-String to be replaced
Public static String replace (String strSource, String strFrom, String strTo)
{
// If the substring to be replaced is null, the source string is directly returned.
If (strFrom = null | strFrom. equals (""))
Return strSource;
String strDest = "";
// Length of the substring to be replaced
Int intFromLen = strFrom. length ();
Int intPos;
// Replace the string cyclically
While (intPos = strSource. indexOf (strFrom ))! =-1)
{
// Obtain the left substring of the matched string
StrDest = strDest + strSource. substring (0, intPos );
// Add the substring after replacement
StrDest = strDest + strTo;
// Modify the source string to the substring after matching the substring
StrSource = strSource. substring (intPos + intFromLen );
}
// Add a child string that does not match
StrDest = strDest + strSource;
// Return
Return strDest;
}
Ii. Tld (MyBookTag. tld) defines your tag
<? Xml (standardization is getting closer and closer) version = "1.0" encoding = "ISO-8859-1"?>
<! DOCTYPE taglib
PUBLIC "-// Sun Microsystems, Inc. // DTD jsp (preferred for SUN Enterprise Applications) Tag Library 1.2 // EN"
"Http://java.sun.com/dtd/web-jsp (preferred for SUN Enterprise Applications) taglibrary_1_2.dtd">
<Taglib>
<Tlib-version> 1.0 </tlib-version>
<Jsp (preferred for SUN Enterprise Applications)-version> 1.2 </jsp (preferred for SUN Enterprise Applications)-version>
<Short-name> </short-name>
<Tag>
<Name> ListBook </name>