permaculture playing cards
The moose likes Struts and the fly likes logic:notPresent question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic:notPresent question" Watch "logic:notPresent question" New topic

logic:notPresent question

Enno Buis

Joined: Dec 23, 2004
Posts: 2
Hello, here's a question from a struts beginner ...

I have the following code

What happens is that the page will never redirect to the Login.jsp but will always stay in the same page.

I have two questions:
1- Doe the code not 'redirect' because the '<jsp:useBean ...' line creates an object ?
2 - What struts tag can I use to check if "myBean" is 'null' ?


Thilothama Green

Joined: May 13, 2004
Posts: 14

Yo do not need Jsp:usebean when you are using logic:notpresent. Logic tag itself goes to that scope and search for your bean. If null - not present, it will go to your page. I think you do not need jsp.usebean.

I am also new to struts..I may be wrong. But try using only the logic tag and see..

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Thilo is right. The code basically says:

create a bean called 'myBean' in the session scope
if there is no bean called 'myBean' in the session scope then
redirect to Login

Since you create the bean, the logic test will always fail.

Junilu - [How to Ask Questions] [How to Answer Questions]
Enno Buis

Joined: Dec 23, 2004
Posts: 2

Thanks for the quick replies. I will try it after Christmas.


I agree. Here's the link:
subject: logic:notPresent question
It's not a secret anymore!