jtharp (4) [Avatar] Offline
#1
My question: in your book you show a servlet class with a single Xdoclet tag (@web.servlet). In the following paragraph you point out that you intentionally do not configure the servlet with further Xdoclet tags because configuration in java files is bad form (my paraphrase). While I agree with the principle, I don't see anywhere in your book how I do configure that servlet. With the tag in the java file, the deployment descriptor entry is generated in web.xml, but what do I have to do to get my settings in place?

Thanks
ErikHatcher (211) [Avatar] Offline
#2
Re: Configuring Servlets w/o Xdoclet
XDoclet uses merge files to allow configuration outside of @tags. Look at our source code for the build file and you'll see that we specify a mergeDir on the webdoclet task. In the directory specified are the merge files that end up in web.xml.
jtharp (4) [Avatar] Offline
#3
Re: Configuring Servlets w/o Xdoclet
So does that mean that the example code which shows a @web.servlet tag is not used? I also found an example in your InitServlet where you used the @web.servlet tag. How would you further configure that Servlet? Would you need to delete the tag and include a <servlet> descriptor in the merge file?
ErikHatcher (211) [Avatar] Offline
#4
Re: Configuring Servlets w/o Xdoclet
> So does that mean that the example code which shows a
> @web.servlet tag is not used? I also found an example
> in your InitServlet where you used the @web.servlet
> tag. How would you further configure that Servlet?
> Would you need to delete the tag and include a
> <servlet> descriptor in the merge file?

You may find the info here helpful: http://www.ehatchersolutions.com/JavaDevWithAnt/xdoclet.html

The way I've typically done this (and to be honest, XDoclet is no longer part of my builds - I do not use Struts or EJB any longer) is to define the servlet in XDoclet tags, but define the servlet _mappings_ in the merge file. So @web.servlet stays in code and mappings of those servlets to actual paths go in merge files. The code shown in the book and sample code is accurate in these regards.
jtharp (4) [Avatar] Offline
#5
Re: Configuring Servlets w/o Xdoclet
So if you don't use XDoclet, Struts, and EJBs anymore, what do you use? (you can't just leave a juicy morsel out there like that, come on!)

Ok, I think I finally get it... My one point of confusion (and perhaps I wasn't clear about this to begin with) is that I'm looking at replacing some hand-coded deployment descriptors. The hand-coded servlet descriptor includes several parameters. What I've been trying to figure out is how you get a merge point in the middle of a XDoclet-generated <servlet> tag. If I'm understanding your responses correctly, this type of configuration maybe should be in a properties file included in the WAR, not in the descriptor at all. Otherwise, I'm back to hand coding the descriptor right? Well, at least the servlet descriptor, by having to write the servlets.xml template merge file.

Have I finally gotten it?
ErikHatcher (211) [Avatar] Offline
#6
Re: Configuring Servlets w/o Xdoclet
Tapestry and Lucene!
jtharp (4) [Avatar] Offline
#7
Re: Configuring Servlets w/o Xdoclet
Sorry, I added a question to my previous post, apparently at about the same time that you posted your reply.

Thanks for all your help!

Josh
ErikHatcher (211) [Avatar] Offline
#8
Re: Configuring Servlets w/o Xdoclet
You can't get a merge point in the middle of a servlet definition (look at the .xdt files inside of XDoclet's web JAR for the gory details). You can, however, use Ant properties and the ${...} syntax in XDoclet @tags to put dynamic information in there.