JSTL xmlns namespace differences between JSF 1.2 and JSF 2.x?
Asked Answered
H

2

23

I have a JSF 1.2 based webapp from which I copied the JSTL import

xmlns:c="http://java.sun.com/jstl/core"

You can also find this import in many places on the Internet. I can't remember whether the above worked in my former web project or not, in any case, it does not work in my current JSF 2.0 based webapp. I got a warning from the container saying:

Warning: This page calls for XML namespace http://java.sun.com/jstl/core declared with prefix c but no taglibrary exists for that namespace.

I then changed the import to

xmlns:c="http://java.sun.com/jsp/jstl/core"

... which removed all headaches using <c:forEach> in a JSF/RichFaces-based webapp.

What's the trick here? Have there been any changes to the JSTL import URL from JSF 1.2 to 2.x? Or is the former line generally wrong (in JSF)? What's the difference between the two?

Horticulture answered 29/9, 2011 at 7:1 Comment(0)
M
46

Check our JSTL wiki page: https://stackoverflow.com/tags/jstl/info You can get this kind of page whenever you hover the tag below your question until a black box pops up and then click the info link.

It is true that Facelets 1.x and 2.x uses different namespaces for the JSTL tag library. It was less or more a namespace bug in Facelets 1.x and has been fixed for Facelets 2.x.

  • The real JSTL 1.0 taglib uses the URI http://java.sun.com/jstl/core.
  • The real JSTL 1.1/1.2 taglib uses the URI http://java.sun.com/jsp/jstl/core.
  • Facelets 1.x uses the URI http://java.sun.com/jstl/core.
  • Facelets 2.x uses the URI http://java.sun.com/jsp/jstl/core.
  • Facelets 2.2+ uses the URI http://xmlns.jcp.org/jsp/jstl/core.

You can find all Facelets 2.x tags in the Facelets tag library documentation. Facelets don't ship with the full tag set as the real JSTL taglib. Only a few of the <c:xxx> and the full set of <fn:xxx> are copied into Facelets. The <fmt:xxx>, <sql:xxx> and <xml:xxx> tags are not taken over in Facelets.

Makeyevka answered 29/9, 2011 at 14:1 Comment(1)
Facelets 2.2+ namespace URI is http://xmlns.jcp.org/jsp/jstl/core (just follow the JSTL tag info as described by BalusC)Horticulture
W
3

JSTL is now part of EL.
It is not dependent on JSF implementation but depends on what servlet version your servelet container is compliant for.
So these must be running of different servers or different versions of same server.


Short answer is from 2.4 upwards which jboss 7 is .
If you go through JSTL doc here you will find out any way.
Other wise here is good link.
And an other one here from BalusC.

Wittenberg answered 29/9, 2011 at 7:14 Comment(1)
How do I find out which server uses which namespaces? I'm currently using JBoss AS 7.Horticulture

© 2022 - 2024 — McMap. All rights reserved.