This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Split web.xml into smaller manageable xml files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Split web.xml into smaller manageable xml files" Watch "Split web.xml into smaller manageable xml files" New topic
Author

Split web.xml into smaller manageable xml files

Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Hi all,

For projects that have big web.xml and many developers working on it, is it possible to split it into smaller separate manageable XML files? I tried using the <!ENTITY filter SYSTEM "filter.xml"> to replace my <filter> tags but gotten parser errors.

Anyone done something of this before? Is it feasible?

Many thanks!


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Nope, I don't think that you can split the Deployment Descriptor.


[My Blog]
All roads lead to JavaRanch
Praveen Babu
Ranch Hand

Joined: Jul 30, 2006
Posts: 138
Originally posted by Chengwei Lee:
Hi all,

For projects that have big web.xml and many developers working on it, is it possible to split it into smaller separate manageable XML files? I tried using the <!ENTITY filter SYSTEM "filter.xml"> to replace my <filter> tags but gotten parser errors.

Anyone done something of this before? Is it feasible?

Many thanks!



Hi,
I have split the struts-config.xml file into 2 files like this

In struts-config.xml use

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd"[

<!ENTITY actions SYSTEM "actions.xml">

]>

<!-- =============== Mappings in actions.xml ===================== -->
&actions;

and actions.xml is a normal xml file.

Use this to split web.xml. I have never tested it with web.xml so tell me if it works.

Regards,
Praveen
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Hi Praveen,

Thanks for the example, seems that Satou is right, the DD cannot be splitted. Tried following your example to breakdown the web.xml but the server complained malformed XML.

Cheers!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

If the web.xml is so big because you have many individual servlet definitions, your app could benefit from using a Front Controller. Please read this article for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Originally posted by Bear Bibeault:
If the web.xml is so big because you have many individual servlet definitions, your app could benefit from using a Front Controller. Please read this article for more information.


I know what you mean, unfortunately it's a live application and any major refactoring work has to be done in small incremental stages. A front controller is what we're working towards, but meanwhile, it would be good if we could breakdown the web.xml.

Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
You can split the web.xml into smaller manageable files:


<?xml versionfiltered="1.0" standalone="no"?>
<!DOCTYPE webapp [
<!ENTITY servlets SYSTEM "servlets.xml">
]>
<webapp>
&servlets;
</webapp>

where servlets.xml has

<servlet>
<servlet-name>blah</servlet-name>
<display-name>blah</display-name>
<servlet-class>blah.blahclass/servlet-class>
</servlet>
.....


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
what version of tomcat are you using? the latest version 5.5.17 should support it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Split web.xml into smaller manageable xml files
 
Similar Threads
what is displaytag filter. How is it used ?
Unable to deploy the file in Tomcat
Gzip Filter in Web Application
Struts 2+Tiles+Spring Core+Spring Security
Jsp is not displaying in Struts2