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

secmaska at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

Ksushaa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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 ?

secmaska at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Yes, I meant that I am using *.xhtml files

Sorry if I was unclear

Ksushaa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Are you actually getting compilation errors? That's odd. Are you sure that you're not in confusion with validation errors/warnings?

BalusCa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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">

Ksushaa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

the web container will ignore java code in *.html or *.xhtml , i think simple to rename them to *.jsp.

secmaska at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

I cant:)

Ksushaa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

Are you using facelets?

RaymondDeCampoa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

yes i am

Ksushaa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-available-jstl

RaymondDeCampoa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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>

secmaska at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

Ksushaa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

RaymondDeCampoa at 2007-7-28 17:58:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 15

yes, i was wrong, in somewhere , Faces Servlet always search for *.jsp and i don't know how to change this default config.

secmaska at 2007-7-28 17:58:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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"

Ksushaa at 2007-7-28 17:58:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...