Search in sources :

Example 1 with TagLibraryValidator

use of jakarta.servlet.jsp.tagext.TagLibraryValidator in project tomcat by apache.

the class TagLibraryInfoImpl method validate.

/**
 * Translation-time validation of the XML document associated with the JSP
 * page. This is a convenience method on the associated TagLibraryValidator
 * class.
 *
 * @param thePage
 *            The JSP page object
 * @return A string indicating whether the page is valid or not.
 */
public ValidationMessage[] validate(PageData thePage) {
    TagLibraryValidator tlv = getTagLibraryValidator();
    if (tlv == null) {
        return null;
    }
    String uri = getURI();
    if (uri.startsWith("/")) {
        uri = URN_JSPTLD + uri;
    }
    return tlv.validate(getPrefixString(), uri, thePage);
}
Also used : TagLibraryValidator(jakarta.servlet.jsp.tagext.TagLibraryValidator)

Example 2 with TagLibraryValidator

use of jakarta.servlet.jsp.tagext.TagLibraryValidator in project tomcat by apache.

the class TagLibraryInfoImpl method createValidator.

private TagLibraryValidator createValidator(ValidatorXml validatorXml) throws JasperException {
    if (validatorXml == null) {
        return null;
    }
    String validatorClass = validatorXml.getValidatorClass();
    if (validatorClass == null || validatorClass.isEmpty()) {
        return null;
    }
    Map<String, Object> initParams = new Hashtable<>(validatorXml.getInitParams());
    try {
        Class<?> tlvClass = ctxt.getClassLoader().loadClass(validatorClass);
        TagLibraryValidator tlv = (TagLibraryValidator) tlvClass.getConstructor().newInstance();
        tlv.setInitParameters(initParams);
        return tlv;
    } catch (Exception e) {
        err.jspError(e, "jsp.error.tlvclass.instantiation", validatorClass);
        return null;
    }
}
Also used : Hashtable(java.util.Hashtable) TagLibraryValidator(jakarta.servlet.jsp.tagext.TagLibraryValidator) URISyntaxException(java.net.URISyntaxException) JasperException(org.apache.jasper.JasperException) IOException(java.io.IOException)

Aggregations

TagLibraryValidator (jakarta.servlet.jsp.tagext.TagLibraryValidator)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 Hashtable (java.util.Hashtable)1 JasperException (org.apache.jasper.JasperException)1