A Practical Guide for Integrating EJB and Struts : Page 5
EJB and the Struts framework each have received plenty of coverage individually, but what about leveraging EJB and Struts together? This tutorial lays out a complete step-by-step guide to integrating these two technologies.
by Stephen Lum
May 19, 2004
Page 5 of 7
Create a Merge Directory
Before you generate your Web deployment descriptors, you should create a merge directory and split up the original web.xml that came with the struts-blank.war import. To do so, create several XML files. When you run XDoclet, it will take these other XML files and re-generate web.xml. Alternatively, you can simply generate the web.xml entries in another file, and then paste them into your original web.xml. However, for a longer-term solution that eliminates the need to continually copy and paste these entries, I recommend creating the merge directory and splitting up the original web.xml:
Create a new directory called merge under your project root.
Create a servlet-mappings.xml file under the merge directory and enter the following:
Right click webdoclet in the left white box. Click Add, choose deploymentdescriptor, and click OK. Now select deploymentdecriptor (you may have to expand the webdoclet node if you don't see it), check destDir, and set the value to WEB-INF. Next, check mergeDir and set that value to merge (see Figure 13).
Figure 13: Add deploymentdescriptor to the webdoclet
Right click webdoclet. Click Add, choose jbosswebxml, and click OK. Select jbosswebxml, make sure destDir is checked, and set the value to WEB-INF. Set Version to 3.0 and check it. Click OK (see Figure 14).
Right click webdoclet. Click Add, choose fileset, and click OK. Select fileset, make sure destDir is checked, and set the value to WEB-INF/src/java. Uncheck excludes. Next, make sure includes is checked and set the value to lum/webdoclet/WebDoclet.java. Click OK (see Figure 15).
Now, click OK at the bottom right corner. Eclipse will generate an xdoclet-build.xml file. To run your XDoclet file, right click on your project StrutsEJBTutorial in the package explorer, and then click Run XDoclet.
You will see that XDoclet generated both your Web deployment descriptors, web.xml and jboss-web.xml, in your /WEB-INF directory. You'll also notice that XDoclet used the various XML files in your /merge directory to recreate your original web.xml file.