wood burning stoves 2.0*
The moose likes Struts and the fly likes How to check against null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to check against null" Watch "How to check against null" New topic
Author

How to check against null

surendar prabu
Ranch Hand

Joined: Jul 24, 2006
Posts: 102
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 ]

SCJP 1.4
Mahesh Desai
Ranch Hand

Joined: Apr 04, 2007
Posts: 76
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

Joined: Apr 04, 2007
Posts: 76
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to check against null
 
Similar Threads
Handling Session TimeOut
c:if tag not working as expected
About using logic:equal
Help with the tag library..
[Struts] Comparing with null using equal tag