• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Debug JSTL

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to JSTL and I'm trying to debug a forEach statement that is iterating through the columns in one row pulled from a database. The value of the column is not printing correctly when it's empty and I'm having a hard time figuring out why. Here is the code:



If the value is not empty, the value is displayed. While if it IS empty, the "-" should display (but it's not). In fact I can't get anything to display if the value of the column variable is blank/null.

Two questions:

1) Does anyone know what is wrong with this ternary statement?

2) Is it possible to print out the value of the column variable using a scriptlet and System.out.println so that I can have a clue what is going on with this variable?
 
Sheriff
Posts: 67746
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
A couple of things:

1) Please check the 'disable smilies' checkbox when posting code. That way, your <c:out> tags will look less surprised! :o

2) I am assuming JSP 2.0 and JSTL 1.1? The ternary operator is not supported in earlier versions.

3) The forEach tag will create its var in pageContext, so for debugging purposes you could fetch it from there in order to examine it.
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the pageContext hint. I was able to get the SQL statement that was being called and when I run that directly against the database, the statement returns ALL columns. However, when I run it in through the JSP it is actually skipping 3 of the columns.

However I've found that if I change the


To



All the columns are displayed. What could the "rowsByIndex" be doing here to hide some of these columns?

Thanks,
Jim
 
Bear Bibeault
Sheriff
Posts: 67746
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 could the "rowsByIndex" be doing here to hide some of these columns?



You'd have to look at the getRowsByIndex() method of whatever 'stats' is to find out.
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for the suggestions. I found the problem, and it wasn't on the rows or rowsByIndex (although I am still not sure why "rows" was working when according to my debugging, it shouldn't have). The issue was with the



line. The variable "date_format" was null and I suppose these JSTL tags must do some sort of error handler because there was no null pointer exception being thrown.

For anyone who is curious, I had to tear apart the "stats" variable which was a Result object to look at what getRowsByIndex returned and this is how I did it.

 
Do you want ants? Because that's how you get ants. And a tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic