aspose file tools*
The moose likes Struts and the fly likes JSTL Expression issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSTL Expression issue" Watch "JSTL Expression issue" New topic
Author

JSTL Expression issue

Richard Cook
Greenhorn

Joined: Aug 18, 2010
Posts: 22
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

Joined: Jan 10, 2002
Posts: 60997
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Richard Cook
Greenhorn

Joined: Aug 18, 2010
Posts: 22
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

Joined: May 14, 2004
Posts: 511
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

Joined: Aug 18, 2010
Posts: 22
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

Joined: Jan 10, 2002
Posts: 60997
    
  65

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

Joined: Aug 18, 2010
Posts: 22
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

Joined: Jan 10, 2002
Posts: 60997
    
  65

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

Joined: Jul 06, 2005
Posts: 1018
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

Joined: Jan 10, 2002
Posts: 60997
    
  65

I've moved this to the Struts forum.
Richard Cook
Greenhorn

Joined: Aug 18, 2010
Posts: 22
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL Expression issue