File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes how we will  check session objects in  logic:present tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how we will  check session objects in  logic:present tag" Watch "how we will  check session objects in  logic:present tag" New topic
Author

how we will check session objects in logic:present tag

Praveen Kumar
Ranch Hand

Joined: Nov 06, 2006
Posts: 133
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

Joined: May 24, 2003
Posts: 425
It's possible you misspelt the session attribute. You can dump the whole session content to see the attributes stored.
Praveen Kumar
Ranch Hand

Joined: Nov 06, 2006
Posts: 133
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

Joined: Feb 15, 2005
Posts: 4864
Did you remember to put a taglib declaration for the "logic" tag library at the beginning of the JSP?


Merrill
Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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 ]
 
wood burning stoves
 
subject: how we will check session objects in logic:present tag
 
Similar Threads
How does everyone else handle table entries and null values?
logic:notPresent question
My logic Tag Does Not Seem To Work
bean value persists on clicking back
Problem with a select tag