2

I have this use case where an index.xhtml page is created by a JavaScript framework. This page contains following element:

<link rel="stylesheet" href="/design/style/sheet/css-effects.css">

The page starts with following doctype, which is standard for HTML5 documents:

<!DOCTYPE html>

When this file then gets parsed by JSF 2.3, it generates following error:

javax.servlet.ServletException: Error Parsing /index.xhtml: Error Traced[line: 22] The element type "link" must be terminated by the matching end-tag "</link>"

However, JSF 2.3 states that it is HTML5 compatible. There are many articles about it on the internet.

When I then go to the definition of the HTML5 link element, it clearly states that the link element can be used as generated above, meaning with only '>' at the end, and not with '/>' or a complete closing tag like '>':

https://html.spec.whatwg.org/multipage/semantics.html#the-link-element

Thus, in fact the JavaScript generates correct HTML5 syntax following the standards. And apparently JSF cannot handle correct HTML5 syntax. It not only happens with the link element, but also with img and so on... Elements that will never have content in fact.

So, my question is: is it true that JSF 2.3 in the end is not fully compatible with HTML5, but only partially? Is there a way to bypass this behaviour of JSF to refuse HTML5 compatible elements or should I configure something? Or am I completely missing something important here?

It is important for me to know, because I have no control on how the JavaScript framework generates html files. And in the end, they are formatted correctly.

onderbewustzijn
  • 935
  • 7
  • 32
  • @BalusC I was afraid of this, and it is a real bummer. So I guess as a workaround I should 'fix' those elements in order to let them be parsable by JSF. If I may ask, any quick solution for this in mind? Something dirty like using a servlet before the Faces Servlet is loaded and add the necessary forward slashes to the elements? – onderbewustzijn Nov 14 '20 at 18:11
  • @BalusC well, imagine you have an xhtml page with the link element I mentioned (meaning without the self closed tag). Now, with a filter or servlet (before JSF processing) that edits the page and changes the link element to have a self closed tag. Idea: https://www.codejava.net/java-ee/servlet/how-to-modify-http-response-using-java-filter. But this is to edit the page after JSF processing, and thus it will not render the page. If we can find something like this, it might even be a global solution for making JSF completely HTML5 compatible by simply dynamically adding self closed tags :-) – onderbewustzijn Nov 15 '20 at 00:30
  • @BalusC I agree it might seem an xy problem. The files are generated by Vue, and they adhere to the HTML5 standard. Then they are added to a JSF enabled project. However the Facelet Servlet throws errors on the open tags like link. You could state that Vue is up to date to fully use that latest HTML standard. So the problem still remains on the JSF side, which claims to be HTML5 compatible. But saying that they only can be XML (or XHTML) compatible is then a contradiction. Of course, JSF is to blame. Anyway, a similar solution like the one from codejava but before the chain.doFilter method? – onderbewustzijn Nov 18 '20 at 15:27

0 Answers0