struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From panti...@firstenergycorp.com
Subject Re: Can't figure out how to do "if then else" with Struts logic tags
Date Tue, 18 Apr 2006 17:50:20 GMT
Dave,

I totally agree with you about doing this kind of checking in an action
class and I AM doing it there. However, the problem is that I still need a
way to prevent a user from going to the jsp w/o first logging in.

Let's say the user logged in during a previous session and bookmarked the
jsp.  They can get back to it w/o having to login. I know that once they
submit the form  the action class will catch that they're not logged in and
send them back to login page. But I'd rather catch it before then. I hate
to have the user fill in a bunch of information, submit form and THEN get
redirected to login.

I'll look into JSTL. Are you saying it has "if-then-else" type of
processing? Could you point me in the right direction for that and for the
"check if object exists in session" issue?

Also, I haven't used filters before. We just upgraded from Struts 1.0.2 so
I'm pretty ignorant of all the features of newest version of Struts. Is
this some kind of Struts filter or what is described here?
http://java.sun.com/products/servlet/Filters.html

Thanks again for your reply.

pantichd@firstenergycorp.com wrote:
> 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
> link  http://struts.apache.org/struts-doc-1.2.7
/userGuide/struts-logic.html
>

Use JSTL; you'll be better off in the long run anyway, and there's
essentially zero learning curve.



> 1) I want to put in some logic in all my jsps to check if a user has
> authenticated.
>

Don't do this in the JSP; do this in either a filter, base Action class,
etc. Try to use JSP pages for presentation only to keep concerns separated.

> 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?
>

Again, if you're doing this outside of a JSP (highly recommended) it's
trivial. Otherwise you could always use a JSTL tag to check for a value
in the appropriate session scope attribute key.

Als0-Dave




David


-----------------------------------------
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message