Custom JSP taglib lets you present tag's body as XML data. This taglib lets you reuse the existing content in your Ajax applications for example. Tag presents own body as XML CDATA content, so your JavaScript XML parser will be able to extract HTML code wrapped by XML tags. For example, suppose your Ajax application needs to obtain HTML content prepared by JSP file and use this content for the updating some div block (via innerHtml property).
In this case the requested JSP file must present own data in XML format. So without the converting it to XHTML you can simply
wrap it with Ajax preparation taglib:
In this case tag will produce the following XML file:
Now in your Ajax application you can get the value for node
mycode and it will keep the HTML content prepared in the requested JSP file.
The following code illustrates the main idea:
Here req.open("GET","our_file.jsp",true) requests our JSP file. And Ajax preparation taglib lets you take the existing JSP code "as is" and return it in XML format. Function callback parses the response and obtains the value for XML tag mycode.
You can perform the similar task with Java servlets filter. See Ajax preparation filter in JSOS.
Tags are:
toAjax
Body tag presents own body as XML data. Parameters are:
for downloading:
Library: toajaxtag.jar
Description: taglib.tld
See also Coldtags suite - the largest collection of custom JSP tags.
2) contentType Optional parameter. Possible values are true or false.
If this value is true than tag will set content type for the output to text/xml. Default value is false.