• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with JSTL

 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i am running a query in jstl. in c:forEach i have something like this



now i want that if no record i featched then there should be a message like "No Data Found!!". for this i am using below code ----




but it's not working. can somebody please suggest me what will be the value of viewRowsad[0] in case no record is featch. please take note in my case i can't make additional query to first check that if there is data in the table for user. if want to make this in a single query.
 
Darren Edwards
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If you are checking for a null you should not be wrapping it in ' ' (that treats it as a String).

Am not 100% certain without testing myself, but I think you can also say
 
Stefan Evans
Bartender
Posts: 1784
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually if no rows are retrieved, then the rowCount of the query result will be 0.
You can test it like this:



If no rows are returned, the c:forEach won't even iterate once.
 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Stefan, your code workes for me.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic