• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JSTL c:if not working, but c:out is working

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am migrating from Resin 3.0.14 to Resin 3.1.0. Everything seems to work fine, except for inconsistencies in JSTL - All jtsl 'if' tags are not working!

example:
adding this to my JSP -
<c:out value="${sessionScope.userSession.sessionValid==true}"/>

outputs a value of 'true' or 'false' based on the value of the variable 'sessionValid' in the 'userSession' bean in the HttpSession object.

but -
<c:if test="${sessionScope.userSession.sessionValid==true}">
<c:out value="${sessionScope.userSession.sessionValid}"/>
</c:if>

does not work. and neither does -
<c:if test="${sessionScope.userSession.sessionValid!=true}">
<c:out value="${sessionScope.userSession.sessionValid}"/>
</c:if>

I dont get any output from the JSP as all.

Clear JSTL is working, but only partly! I tried using c:choose, but even that did not work :-(
What could i be doing wrong?

TIA
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you can test to see if <c:if> is working in general (as I'm usre that it is) with a small JSP file such as:



If you see "true" on the browser, <c:if> is working.

What remains is to debug your test expression.

[Added: don't forget to declare the JSTL in your page]
[ April 05, 2007: Message edited by: Bear Bibeault ]
 
Ankush Bhargava
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, thanks for you reply.

I tried the code snippet you gave, and the output was -
"${result}"

so i tried:


and i got -
false

what next?
 
Ankush Bhargava
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, thanks for you reply.

I tried the code snippet you gave, and the output was -
"${result}"

so i tried:


and i got -
false

what next?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Well, you can test to see if <c:if> is working in general (as I'm usre that it is) with a small HTML file such as:



Did you mean a small ".jsp" file or does Resin support JSTL in files with HTML extensions?
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoopsy. Of course it's a JSP. My bad.

I've gone back and fixed the typo...

Ankush, my apologies. Please be sure that it's a JSP file and re-run to see the results. And don't forget to declare the JSTL c library in your page.

Good catch Ben!
[ April 05, 2007: Message edited by: Bear Bibeault ]
 
Ankush Bhargava
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey no worries. I did try running the code on a JSP and not an HTML.

Infact here's exactly what i ran -


output -
false | true


I've tried many combinations of values inside the c:if tags and none seem to work.
c:out always works.
 
Ankush Bhargava
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh, and this code runs just fine on my 3.0.14 version.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens if you don't use the <c:out>?

Do you still get ${result}?

If so, your web app is not configured to enable the EL in template text and it must be for the JSTL 1.1 to work properly.

What does your web.xml look like? It must declare the app as Servlets 2.4 rather than 2.3. See the JSP FAQ for details.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, are you using Resin's builtin JSTL? Or a 3rd-party library?
 
Ankush Bhargava
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. When i don't use the c:out, I get back what I wrote. i.e. the output is -
${result}

2. Resin documentation says that default is JSTL turned on. So i haven't played with that part.
How can I toggle it?

3. web.xml -
<web-app xmlns="http://caucho.com/ns/resin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">


4. I guess I'm using the Resin's built in JSTL, as I did not explicitly add any JSTL jar file to the build.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ankush Bhargava:
1. When i don't use the c:out, I get back what I wrote. i.e. the output is -
${result}



This is an issue. Does it work in your Resin 3.0 installation?

Until you get this working, all other bets are off.

We're using Resin 3.0.17 so I don't have a 3.1 installation to test against.

2. Resin documentation says that default is JSTL turned on. So i haven't played with that part.
How can I toggle it?



It's not the JSTL that's an issue but the EL. For some reason EL in template text is not being evaluated and it must for the JSTL to work correctly.

3. web.xml -



Hmm, that looks ok.
 
Ankush Bhargava
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm, i see what your point.

I also tried running this against a Resin 3.0.23 installation. And that din't work either.
Now i am beginning to think if my configuration is not messy...?

Any tips on getting EL to work?
 
Ankush Bhargava
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally found the cause -
The build file had a 'resin-web.xml', and that skipped my sight. I added the namespaces
' xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core" ' to the web-app tag and presto! EL started working.

Thanks for your help bear. Appreciate it!
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whew! I'm glad you got it working!
 
Oh the stink of it! Smell my tiny ad!
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic