Not sure if this is a solution for you or not, but you could also put
your JSPs under WEB-INF
directory so that they cannot be directly accessed by a user. They
would instead have to go
through an Action first.
Filters may be your best bet (and yes, that is the URL to look at).
As far as JST syntax, you could use something like:
<c:choose>
<c:when test="${numberOfResults==0}">
<!-- DO SOMETHING -->
</c:when>
<c:otherwise>
<!-- DO SOMETHING ELSE -->
</c:otherwise>
</c:choose>
Hope that helps!
Matt
[EMAIL PROTECTED] wrote:
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.
[EMAIL PROTECTED] 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]