struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Can't figure out how to do "if then else" with Struts logic tags
Date Tue, 18 Apr 2006 17:01:15 GMT

Is it possible to do "if then else" type of processing using Struts Logic
tags? I don't see anything in the Struts Logic tags documentation at this

Here's my situation:
1) I want to put in some logic in all my jsps to check if a user has
2) If user has not then I want the page to display a simple message saying
that login is required and include a link back to login page.
3) If user HAS authenticated I want the page to display the normal "stuff"
(e.g. content, struts form, etc) that the page is intended for.
4) Upon valid login, a user object is placed in session and it will have a
boolean property called "authenticated"

I know I could do something like this

<logic:equal name="user" property="authorized" value="false">
      <h3>You must be logged in to view this page. Please login <a href=
<logic:equal name="user" property="authorized" value="true">
      Thank you for loggin in... Normal "stuff" for this page

One of the problems is that I also need to check if the user session object
is null because a user could have tried to go directly to an "internal"
(after login page) page using a bookmark. How can I check for the presence
of an object in the session?

Any help would be greatly appreciated.



The information contained in this message is intended only for the
personal and confidential use of the recipient(s) named above. If
the reader of this message is not the intended recipient or an
agent responsible for delivering it to the intended recipient, you
are hereby notified that you have received this document in error
and that any review, dissemination, distribution, or copying of
this message is strictly prohibited. If you have received this
communication in error, please notify us immediately, and delete
the original message.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message