• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to check against null

 
surendar prabu
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to check for null for one of my request attributes. Consider this , In my login page i check for a request attribute which contains the message saying whether the user is invalid. That is for normal login and specifying invlid login i am using same JSP. If the user is invalid, I set a request attribute with a message. For this i need to check for the request attribute itself for null. How can i check this using logic:equal tag or c:if tags. i dont want to use scriptlets.

Basically in any scope how can i check a value or an attribute for null using logic:equal or c:if or other tag

please help me on this regard.

regards,
Surendar prabu.R
[ April 12, 2007: Message edited by: surendar prabu ]
 
Mahesh Desai
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Surendar,

You can use <logic:notEmpty> struts tag to evaluate the nested body content of this tag if the requested variable is neither null, nor an empty string, nor an empty java.util.Collection.

<c:if test="${empty param.XXXXX}">

Also the above core tag <c:if>, will test whether the request parameter XXXXX is empty. It will True if the request parameter named XXXXX is null or an empty string.


Thanks,
Mahesh

--------

SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - Preparing...
 
Mahesh Desai
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Surendar,

You can use <logic:notEmpty> struts tag to evaluate the nested body content of this tag if the requested variable is neither null, nor an empty string, nor an empty java.util.Collection.

<c:if test="${empty param.XXXXX}">

Also the above core tag <c:if>, will test whether the request parameter XXXXX is empty. It will return True if the request parameter named XXXXX is null or an empty string.


Thanks,
Mahesh

--------

SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - Preparing...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic