Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Possible struts bug?

 
KOla Oyedeji
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have discovered that when i start tomcat it is trying to validate my struts-config.xml against a dtd on the web instead of the local copy i have in my web-inf folder, is this a bug or is there a reason for this?
Kola
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the standard XML parser behavior. You can change the DOCTYPE directive to point somewhere else. For example:
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "struts-config_1_1.dtd" >
 
k Oyedeji
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David
Thanks for the reply. As i understood it, the struts.jar was supposed to be the first place it checked. I actually removed the whole dtd section leaving in only the xml declaration and it worked could this have any adverse results?
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by k Oyedeji:
As i understood it, the struts.jar was supposed to be the first place it checked. I actually removed the whole dtd section leaving in only the xml declaration and it worked could this have any adverse results?

Like I say, this is standard XML parser behavior. It looks for the DTD at the URL provided in the DOCTYPE.
The risk associated with it is that no validation can be done other than "well-formedness" on your config file. The result is that (some) errors in your config cannot be caught until they are encountered at runtime. Misspelled attribute names would be a particular issue. Consider, for example,
<forward ndme="notFound" path="/notFound.dhtml" />
Do you see the error? The validator would, and would complain quite loudly! On the other hand, you wouldn't see it at runtime until you would encounter your "notFound" forward, which might be a niche case of a niche action. So some user somewhere ends up staring at the infamous "white screen" symptomatic of a misconfiguration in struts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic