Pre Check web.xml for Errors in Servlets

web.xml file in Servlets (Java)
Sometimes we might be disgusted when we encounter errors related to web.xml while executing our web application, we might not understand it at times even when we look at the Tomcat logs. So in this post i'll discuss about how to pre check the web.xml for errors.
As web.xml  is an xml file, the default application for xml files is Internet Explorer, so open web.xml in Internet Explorer. That's it.

See following, i had intentionally written an error in web.xml (not properly closing the <web-app>.


When i open this in Internet Explorer, the screenshot will look like..

web.xml error in Internet Explorer
web.xml error in Internet Explorer

When i write it correctly, closing the tag properly, it will look like..

Correct way of writing web.xml showed in Internet Explorer
web.xml is displayed in Internet Explorer

Unlike the previous screenshot, in this screenshot you have the web.xml correctly displayed which means that the xml file is well parsed with no errors.

However, errors that are not related to the syntax such as change servlet name in tags i.e. different servlet names in servlet-mapping and servlet tags cannot be identified unless you are familiar with.

This is just a tip that helps you detect xml parsing related errors. Hope this helps.

Posted by at on

Tags: Servlets, Tips,