Class 2 |
Intermediate Java 30-IT-397 |
|
A Parsing Example
-
Let's try this out with a script that will find and replace string text.
-
The string text will be the body between the tags.
-
The tag will have two attributes: add and remove.
-
The tag handler will search the body text for the remove text, and replace
it with the add text.
-
If no remove text is found, the handler will return the string unaltered.
-
The files
-
Replace.java The tag handler class that
does the dirty work.
-
Edit53.jsp A JSP with body text that will
be replaced.
-
EditUSB A JSP with no body text to be
replaced.
-
edit.tld The tag library definition file
for the Replace tag.
-
Don't forget to add this to the web.xml file:
<taglib>
<taglib-uri>/edit</taglib-uri>
<taglib-location>edit.tld</taglib-location>
</taglib>
The Results

Created by: Brandan Jones
December 17, 2001