0

I am using Tomcat 9.

I define a global error page in my web.xml. (As per BalusC's answer in How can I use the same error page for multiple error codes in Tomcat?)

<error-page>
    <location>/error/exception.jsp</location>
</error-page>

It works great. However Eclipse complains that

The content of element type "error-page" must match "((error-code|exception-type),location)".

I could do something like this

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error/exception.jsp</location>
</error-page>

But then I would need to have separate declarations for every single error page. I would like to define something general as a "catch-all"

My assumption was that I would need to update the web.xml version

But changing 1.0 to for instance 2.0 results in the following:

XML version "2.0" is not supported, only XML 1.0 is supported.
gordon613
  • 2,770
  • 12
  • 52
  • 81
  • 1
    The XML declaration is not about your file content, it's about the version of XML itself that applies. You generally have no need to change it. – nitind Jul 28 '22 at 16:33
  • Thanks. So what do I need to change in order to update the syntax-checker of the file content? – gordon613 Jul 28 '22 at 16:50
  • 2
    It is not a syntax problem, your file is invalid for the schema being used. You already know how to fix it for the schema you are using, or alternately you could change what that schema is. As BalusC's answer mentions, error-codes and exception-types are optional with newer schema versions. – nitind Jul 28 '22 at 17:09

1 Answers1

0

Thanks to @nitind, I changed the schema as follows

It was

<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>

And it is now

<?xml version = '1.0' encoding = 'UTF-8'?>
<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

I got the new schema from What does this web.xml error mean? with the addition of the semi-colon, added in several answers there.

gordon613
  • 2,770
  • 12
  • 52
  • 81