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
When i open this in Internet Explorer, the screenshot will look like..
When i write it correctly, closing the tag properly, it will look like..
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.
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>
.
<web-app>
<servlet>
<servlet-name>mys</servlet-name>
<servlet-class>CookieExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mys</servlet-name>
<url-pattern>/co</url-pattern>
</servlet-mapping>
<web-app>
When i open this in Internet Explorer, the screenshot will look like..
web.xml error in Internet Explorer |
When i write it correctly, closing the tag properly, it will look like..
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.
No comments:
Post a Comment