To generate the Web descriptors, we need to create another XDoclet configuration, like we did for our EJB.
Procedure 7.1. XDoclet Web Configuration Creation
You have created a new generation configuration named Web.
Procedure 7.2. Webdoclet Configuration
Our configuration now contains a webdoclet that will produce files in the src/WEB-INF folder.
Procedure 7.3. Fileset Configuration
Our configuration now contains a webdoclet with a fileset that contains the src directory, and all files under it that end in Servlet.java.
Procedure 7.4. Deployment Descriptor Configuration
All of the standard Web deployment descriptors will now be placed in the src/WEB-INF directory (property is inherited from webdoclet).
Procedure 7.5. JBoss Configuration
All of the JBoss-specific Web deployment descriptors will now be placed in the src/WEB-INF directory (property is inherited from webdoclet).
Click OK and the XDoclet configuration for the Tutorial will be saved. Once the configuration is saved, right-click on the Tutorial project and select Run XDoclet. The XDoclet generation will display its output in the console. The output should look like this:
After the generation, you should have a project that looks like this. Note that a WEB-INF folder has been created with the web deployment descriptors (both standard and jboss).
In order to run our servlet, we'll need to create an HTML page that passes it parameters.
Procedure 7.6. Creating the HTML Page
The index.html file is intended to be the default page for the Web application and contains a form that will be posted to the Servlet.
The following content should be copied into the index.html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title> Fibonacci Application </title> </head> <body> <h1>Fibonacci Form</h1> <form action="Compute" method="POST" > <table cellspacing="2" cellpadding="2" border="0"> <tr> <td> Limit : </td> <td> <input type="text" name="limit" value="50"> </td> </tr> <tr> <td> <input type="submit" name="Compute" value="Compute"> </td> <td> <input type="Reset"> </td> </tr> </table> </form> </body> </html>