| Author |
NOT EMPTY or NOT NULL?
|
Daniel Gee
Ranch Hand
Joined: Aug 29, 2003
Posts: 202
|
|
I am uncertain about a JSTL tag that I am using. From a Struts action, I pass a Collection "logdata" in a request scope to my JSP page. Of course, I stored that Collection in an object" "LogData". The Collection "logdata" can be a null because if I do not find any records in the database table, I return a null. Now, I am looking at my JSP page (see the code below). I first set a variable called "logRows" and then test it using "${not empty logRows}". Is it correct?
|
 |
alan do
Ranch Hand
Joined: Apr 14, 2005
Posts: 354
|
|
you could do both... ${not empty logRows || logRows != null}
|
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
"not empty" also does a null check, making it VERY useful. In fact, I never write null checks in JSTL because I always use "not empty". So your usage is correct.
|
A good workman is known by his tools.
|
 |
Daniel Gee
Ranch Hand
Joined: Aug 29, 2003
Posts: 202
|
|
I use the NOT EMPTY to do the testing. But, I got an Internal Server Error 500 problem (The log is shown after my code snippet.) I am unable to see the problem with my <c:when ....> tag.
Root cause of ServletException. javax.servlet.jsp.JspTagException: javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "test" with value "${NOT EMPTY log Rows}": Encountered "EMPTY", expected one of ["}", ".", ">", "gt", "<", "lt", "= =", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "% ", "mod", "and", "&&", "or", "||", ":", "("] (null)
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
Lowercase, partner.
|
 |
 |
|
|
subject: NOT EMPTY or NOT NULL?
|
|
|