JspException.getRootCause() method has been removed in Pages 4.0

This rule flags usage of the JspException.getRootCause() method.

The JspException.getRootCause() method was deprecated in JSP 2.1 and has been removed in JSP 4.0. As of JSP 4.0, developers should use the standard Throwable.getCause() method instead, which provides the same functionality in a more consistent way across Java APIs.

The following example shows invalid usage that will be flagged:


import jakarta.servlet.jsp.JspException;
public class RemoveJspGetRootCauseMethod {	
   public void testGetRootCauseUsage(JspException e) {
      Throwable rootCause = e.getRootCause(); // This will be flagged
    }
}

The following example shows valid usage:


import jakarta.servlet.jsp.JspException;
public class ValidGetCauseMethod {
    public void test(JspException e) {
        Throwable cause = e.getCause(); // This will not flag
    }
}

For more information, see the following resources: