JSF and JSTL
Hello!!
We are currently working on a project with jsf. We are using XHTML and templates. I was wondering - can I use JSTL tags on XHTML files (JSTL tags dont seem to compile actually on XHTML)?
If yes - what setting should I add?
Thanks a lot
[268 byte] By [
Ksushaa] at [2007-11-27 10:29:35]

# 1
you can do like this :
1- copy jstl.jar and standar.jar to WEB-INF/lib
2- add follow to web.xml
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
this for servlet 2.3 , if you are using v2.4 , use this :
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
</jsp-config>
change the *. tld path to yours . this is sampe for core taglib, with others you can do the same,
in jsp file add this line follow <%@ page ...
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
....
and using such as :
<c:out value="hello"></c:out>
you can download jstl library here http://jakarta.apache.org/taglibs/index.html
Message was edited by:
secmask
# 2
Thanks for the reply, but...
the thing is that I am NOT using jsp, I am using XHTML, so my question is how I can use JSTL tags there
# 3
i don't understand what are you trying ? what is problem with a jsp file using xhtml syntax ? , or did you mean that *.html, not *.jsp ?
# 4
Yes, I meant that I am using *.xhtml files
Sorry if I was unclear
# 5
Are you actually getting compilation errors? That's odd. Are you sure that you're not in confusion with validation errors/warnings?
# 6
NO, I am not getting compilation errors, the tag is not being interpreted, or whatever its called
for example if I write <c:out value="111">
i dont see anything on the page, but in the source it just stays the same way (html)
<c:out value="111">
# 7
the web container will ignore java code in *.html or *.xhtml , i think simple to rename them to *.jsp.
# 9
Are you using facelets?
# 11
https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-available-jstl
# 12
hey , i think you can try add this to web.xml
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
# 13
RaymondDeCampo, thank you for the link, but I cant find anything thats is in .xhtml file and has jstl tags.
It seems that they should be on the jsp page only
secmask , your snippet doesnt work:)
Message was edited by:
Ksusha
# 14
I think that is the upshot of the documentation I posted; JSTL has limited support in facelets. Perhaps if you post the specific task you want to use JSTL tags for we can make suggestions. You might also want to try the facelets mailing list for a more focused audience.
# 15
yes, i was wrong, in somewhere , Faces Servlet always search for *.jsp and i don't know how to change this default config.
# 16
Thankx everyone
I solved the problem the following way:
in html tag instead of writing
xmlns:c=" http://java.sun.com/jsp/jstl/core"
must be written
xmlns:c=" http://java.sun.com/jstl/core"