This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Struts and the fly likes bean:define , null checks and logic:present Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Frameworks » Struts
Bookmark "bean:define , null checks and logic:present" Watch "bean:define , null checks and logic:present" New topic

bean:define , null checks and logic:present

madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
I have a <bean:define> in my jsp that is tied to a session variable.
I know that <bean:define> can not handle nulls and need to be handled explictly. To do so i have used <logic:notPresent> to make sure that if bean is not available it is set to null

Here is the code that i am using... for defining the bean .

When i try to perform some computation e.g

i get an error saying "optionsVO" can not be resolved.
However when i define the bean with out the <logic:present> tags i don't get this error.

Why do i get this error? Is there a better way to handle this ?

Thanks in advance

Money for nothing and Java for Free
David Newton

Joined: Sep 29, 2008
Posts: 12617

Yes--do the Java work in the Action/service/etc., not in the JSP.
madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
For some reason i don't want to do the small math in the Action class ...well ?
veeresh soni

Joined: Dec 10, 2009
Posts: 12
Are you doing computation in <logic:present> or outside of it if it is out side then place it in that block and check if it is working or not or define object outside the logic:present tag <% Object obj = null; %>
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: bean:define , null checks and logic:present
jQuery in Action, 3rd edition