Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL Expression issue

 
Richard Cook
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Please can you help?

I have a JSP page with some expressions in and they are not evaluating correctly.

I have the correct web.xml structure and libraries in the classpath.

I have the jstl taglib declared at the top of the page as follows:



I have a string variable declared in a for loop in scriptlet called rcI, which I can output using System.out.println().

I have the following line in my JSP:



And I get the following in the logs:



I dont know what is happening it seems to be just showing blank rather than the value set.

Please can someone help.


Regards



Richard
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you are using 10-year-old versions of JSP and your servlet container, your URI for the JSTL is wrong. Please see the JspFaq for correct values.
 
Richard Cook
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply!

I have changed the taglib to be the following:



And the I have the JSTL 1.1 jars in the classpath.


I still get the same issue, should I be using JSTL 1.2 jars?

I am using Tomcat 7 if that helps.


Regards


Richard
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try outputting the value of required variable "${rcI}" using .
Also from the error this does not seems to be error with JSTL usage. Instead it seems HTML tag is failed to lookup the property.

Regards,
Amit
 
Richard Cook
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,

Outputting a cut of the value does not display due to the JSP not compiling (original error).

But a quick System.out.println of the variable shows the correct value i.e 1.

The initial error is a HTML tag error but caused by the expression evaluating incorrectly.

There is no property called siteId[] but rather a siteId[1] property, the value 1 is not evaluating.


Regards



Richard
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
siteId or sideId? Just being sloppy?

In any case, I assume the property is an indexed property? Or is the property value returning an array or List? Keeping such details secret isn't going to help you get an answer.
 
Richard Cook
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologies it is sideId.

As for the property, I am not too sure, the code is code from a Russian outfit who built the original app, I have been tasked with getting it all up to the 21st century etc and to add more functionality. I am converting it all to run in Tomcat 7 etc.

What I can tell you though is that the property in the ActionForm is declared as follows:



Regards


Richard
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, that looks like an indexed property -- which I rarely use because they're quite cantankerous (as you are discovering).

The only suggestions I might have are: to rewrite the bean to avoid indexed properties, or, now that you know the term "indexed property", use it to look up information on how to make sure that they are declared in an appropriate manner for use with the JSTL and EL.

Sorry for not having a more concrete answer -- but as I said, I avoid indexed properties because they're just too much trouble to deal with.
 
Stefan Evans
Bartender
Posts: 1784
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if this will help or not but there is a 'feature' of the struts tags that I remember from years ago.
If you are providing a dynamic value as an attribute to a struts tag, then it must be completely dynamic, not a mix of static text and expression.


So instead of:
Try


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've moved this to the Struts forum.
 
Richard Cook
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to get this working with a mixture of everyone's comments, still not quite sure how I did it, I can post the code if anyone requires it.

Its all a bit muddled up, just getting it to work, rewrite it at a later date when I have time.

Cheers for all your help


Richard
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic