File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Debug JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Debug JSTL" Watch "Debug JSTL" New topic
Author

Debug JSTL

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
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?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

A couple of things:

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

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

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

Joined: Oct 14, 2004
Posts: 205
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Debug JSTL