Wednesday, February 10, 2010

Did you ever wonder if you can have 2 servlets.xml files?

My new employer uses a machine generated servlets.xml. I'm not sure why someone thought that was a win, but whatever. My new part of the application is being rapidly developed and I didn't want to have to regen the servlets.xml file whever I added something, nor did I want to manually edit a file that says at the top "DO NOT EDIT BY HAND" (even though I did at first).

My solution was to add an entity to the web.xml

So

<!DOCTYPE web-app [

    <!ENTITY servlets SYSTEM "servlets.xml">

]>


Became

<!DOCTYPE web-app [

    <!ENTITY servlets SYSTEM "servlets.xml">

    <!ENTITY objectServlets SYSTEM "objectServlets.xml">

]>



And then futher into web.xml


&servlets;

became

&servlets;
&objectServlets;

And of course I made the objectServlets.xml file in the same dir and format as servlets.xml

No comments :