Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how we will check session objects in logic:present tag

 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to test whether we have session attribute in session using <logic> tag.

The code is :

<logic:NotPresent name="Branch" scope="session">
System.out.println("The branch is not there : From lcommands.jsp");
</logic:NotPresent>
But i am getting output always(Branch is not set also).

Can anybody help me to find out the way to check the session objects thru <logic> tag.

Thanks In advance.
Praveen
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible you misspelt the session attribute. You can dump the whole session content to see the attributes stored.
 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thanks for Your Quick reply. !!

I know how to get session attributes in normal way.

But i want to check session objects in <logic> tag.

Here is the code sample.

First i want to see whether Branch attribute is there or not !!
if(there){ display}
else{select your branch }

These is my requirement.
i setted my Branch as session.setAttribute("Branch",value);(in first)
In second.jsp , i am using as
<logic:notPresent name="Branch" scope="session>
No Branch is selectes...
</logic:notPresent>
<logic resent name="Branch" scope="session>
Display
</logic resent>

But for me both are working !!But it should not right !!

Otherwise is there any mechanisam to fulfill my requirement.


Thanks in Advance
praveen
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you remember to put a taglib declaration for the "logic" tag library at the beginning of the JSP?
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea I would wonder about the missing taglib. If that is not the issue, be sure to use a lower case "n" in your tag (logic:notEqual). Case is important but I think you will get an error if you have the tablib statement in place. You can double check by viewing the source in your browser. If the logic:notPresent tag is not being processed as a JSP tag it will get passed through to the browser.

- Brent
[ November 06, 2006: Message edited by: Brent Sterling ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic