ibm.com/developerWorks
Presented by developerWorks, your source for great tutorials
XDoclet may seem intimidating, but the mappings are quite natural. The first step in
using
webdoclet
is defining the servlet element as XDoclet JavaDoc tags at the class
level in your class as follows:
...
* @web.servlet name="BasicServlet"
display name="Basic Servlet"
load on startup="1"
...
*/
public class BasicServlet extends HttpServlet {
This code generates the following servlet element and subelements in the
web.xml
file:
BasicServlet
Basic Servlet
rickhightower.servlet.BasicServlet
...
1
You may wonder how the
servlet class
was determined. Since the XDoclet task
works like the JavaDoc API, it can get the full classname of the servlet just like the
JavaDoc API get the full classname for the JavaDocs. Not only does this save typing, it
mitigates the likelihood of making mistakes. And then later when you are refactoring
and decide to change the class name or package structure, you don t have to manually
change all of the deployment descriptors. Whew!
Step two: define init parameters for Servlet
After the servlet is defined using the Servlet element, then you can define mappings
and initial parameters.
servlet init param
s are defined in JavaDocs comments
like this:
...
* @web.servlet init param name="hi" value="Ant is cool!"
* @web.servlet init param name="bye" value="XDoc Rocks!"
Page 10 of 49
Enhance J2EE component reuse with XDoclets
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved