JSP Libraries and AJAX
(Page 1 of 5 )
In the first part of this article we learned about AJAX techniques and using AJAX with PHP and JSP. In this part we will try to use some advanced JSP tag libraries to develop feature-rich web applications using AJAX.
We will mainly use AjaxTags an an open source JSP tag library, and JMaki. Let's start developing applications using AjaxTags.
This AJAX Tag Library is a set of JSP tags that simplify the use of AJAX technology in Java Server Pages. Some of the common JSP tags are Autocomplete, Callout, Cascading dropdown, Toggle, Update field, Portlet, Tab Panel.
To use the tag library, you'll need JDK 1.5+ and Servlet container running Servlets 2.3+ and JSP 1.0+ like the Tomcat server. We also need Prototype (prototype.js) from http://www.prototypejs.org, the Scriptaculous library from http://script.aculo.us and the OverLIBMWS library from http://www.macridesweb.com. One fine thing is that the AjaxTags distribution also includes these necessary JavaScript items, CSS and the necessary libraries.
To download AjaxTags please visit the project homepage at http://ajaxtags.sourceforge.net/index.html. After downloading the binary distribution of AjaxTags, extract the compressed (.zip) file and copy the ajaxtags-1.3.jar into your WEB-INF/lib directory. This distribution also has a tag library named ajaxtags.tld. Add the tag library information in your web.xml.
To use the AjaxTags tag library in your JSP page use following code.
<%@ taglib uri="http://ajaxtags.org/tags/ajax" prefix="ajax" %>
You also need to add the necessary JavaScript libraries bundled with AjaxTags distributions. AjaxTags needs the following CSS as well. Include them in the head section. Use the following codes.
<link rel="stylesheet" type="text/css" rel="nofollow" target="_blank" href = "css/ajaxtags.css" />
<link rel="stylesheet" type="text/css" rel="nofollow" target="_blank" href = "css/displaytag.css" />
Using AjaxTags you can request any server side part like Servlets or JSP or any other non-Java applications as long as the response is in the proper format. Different tags have different response parsers. AjaxTags supports plain string or XML as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<ajax-response>
<response>
<item>
<name>Record 1</name>
<value>1</value>
</item>
...
</response>
</ajax-response>
The AjaxTags distribution has some helper classes for generating this XML for Java application.
Next: AjaxTags Tags >>
More JavaScript Articles
More By Mamun Zaman