JSP question

J

jack

Hi all,

I met one problem in JSP testing page:
Page like:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
<c:set var="myvar" value="blabla"/>
<c:eek:ut name="${myvar}"/>
</body>
</html>


I expect the output is "blabla", but the actually output is
"${myvar}". Seems the JSP doesn't treat "${myvar}" as variable.

I am using JWSDP1.3

Thanks in advance.

Jack
 
C

Christophe Vanfleteren

jack said:
Hi all,

I met one problem in JSP testing page:
Page like:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
<c:set var="myvar" value="blabla"/>
<c:eek:ut name="${myvar}"/>
</body>
</html>


I expect the output is "blabla", but the actually output is
"${myvar}". Seems the JSP doesn't treat "${myvar}" as variable.

I am using JWSDP1.3
Does JWSDP1.3 come with tomcat 5 ? If so, it is running JSP 2.0, and you
need to use the rt versions of the JSTL taglibraries.

Changing the taglib declaration to
<%@ taglib uri="http://java.sun.com/jsp/jstl/core_rt" prefix="c" %>
should do the trick.
 
J

jack

Christophe,

Thanks for reply. But after I change to
http://java.sun.com/jsp/jstl/core_rt, I got the following error:

org.apache.jasper.JasperException: The absolute uri:
http://java.sun.com/jsp/jstl/core_rt cannot be resolved in either
web.xml or the jar files deployed with this application.

Here is the versions in JWSDP-1.3
ANT 1.5.4; Tomcat v5; RegExp; Xerces 2.x; Xindice v1.1; Xalan v2.x;
Struts v1.1; BCEL; Apache XML Dsig; Apache xmlenc, XML Security 1_0_6.

It is running on WinXP professional .

Thanks again.

Jack

Are there any other tricks? I am working
 
N

news

um...... isn't it supposed to be <c:eek:ut value="${myvar}"/> ?

me thinks so. at least that's how it is with jstl 1.0.x
 
J

jack

That's what I have in the jsp code. But, instead of give me the value
of "myvar", it just printed out "${myvar}".

Then if I change core to core_rt as Christophe, tomcat won't be able
to parse that file at all, because it can't find core_rt tab lib.
 
I

im2kul[at]comcast[dot]net

jack said:
That's what I have in the jsp code. But, instead of give me the value
of "myvar", it just printed out "${myvar}".

Then if I change core to core_rt as Christophe, tomcat won't be able
to parse that file at all, because it can't find core_rt tab lib.

try changing the uri to:

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

and make sure you use <c:eek:ut value="${myvar}"/> and not the name, as
news had earlier suggested.

-- A
 
J

jack

Thanks for reply.

I can include http://java.sun.com/jstl/core_rt,
but it still didn't show the value of myvar, it still shows "${myvar}".

Is there any other setting I need to change?

Thanks

Jack

im2kul[at]comcast[dot]net said:
jack said:
That's what I have in the jsp code. But, instead of give me the value
of "myvar", it just printed out "${myvar}".

Then if I change core to core_rt as Christophe, tomcat won't be able
to parse that file at all, because it can't find core_rt tab lib.

try changing the uri to:

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

and make sure you use <c:eek:ut value="${myvar}"/> and not the name, as
news had earlier suggested.

-- A
 
S

Scott Yanoff

jack said:
Thanks for reply.

I can include http://java.sun.com/jstl/core_rt,
but it still didn't show the value of myvar, it still shows "${myvar}".

Are you using the newest version of JSTL (1.1, I believe)?
http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html

Also, do you have both jstl.jar and standard.jar in your "lib" directory?

I've had success with things like:
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<c:eek:ut value="${mvar}" />

Make sure you have that trailing slash at the end of the c:eek:ut.
Also, have you tried changing the name of myvar to something else, just
in case there is some weird conflict with the name?

How about referencing the uri locally, as I am doing above?
Do you have the .tld files in your WEB-INF directory?

Good luck,
 
J

jack

Thank you Scott.

I have put those two jar files in both <JWSDP>/common/lib and
<WEBAPPROOT>/WEB-INF/lib. And restart the server several times.

There was no difference. So I am going to try the c.tld solution.

But I don't know what to put in c.tld. Would you please post one for
me?

Thanks in advance.

Jack
 
S

Scott Yanoff

jack said:
Thank you Scott.

I have put those two jar files in both <JWSDP>/common/lib and
<WEBAPPROOT>/WEB-INF/lib. And restart the server several times.

There was no difference. So I am going to try the c.tld solution.

But I don't know what to put in c.tld. Would you please post one for
me?

Didn't the .tld files come with your installation?
In any case, you can get the entire package from
http://java.sun.com/products/jsp/jstl/downloads/index.html

You can pick out what you need from there. The .tld files will go into
the WEB-INF directory.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top