Hi,

with a servlet 2.3 engine (like Tomcat 4,...) you could write a filter checking
for this and then either let the user proceed (if logged on) or reroute to
a login-page (if not).

regards
Alexander

-----Original Message-----
From: Antony Stace [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 28, 2002 2:25 AM
To: [EMAIL PROTECTED]
Subject: AW: Want to check user is logged in every page server]


Hi

In the struts example the method used( as many people have pointed out)
to check that the person requesting the page is logged on is to have at the
top of each jsp a tag like


<custom:checkLogonTag/>

This tag should check to see if some sort of bean is present - this bean
 indicates the user has logged on successfully - (method 1).  
Do I need to do anything else or is this the safest way to ensure a user
is loged on  before serving them the requested page.

Question, is there any point of having some sort of database record to 
indicate a user has loggon on and checking with that database record as well
as the bean in (method 1) that the user is logged on?



Cheers

Tony


>You can do this with a custom tag
>
><custom:checkLogonTag/>
>
>of course you also need to implement this tag.
>this is what actually does the job:
>public int doEndTag() throws JspException {
>
>       // Is there a valid user logged on?
>       boolean valid = false;
>       HttpSession session = pageContext.getSession();
>       if ((session != null) && (session.getAttribute(name) != null))
>           valid = true;
>
>       // Forward control based on the results
>       if (valid)
>           return (EVAL_PAGE);
>       else {
>           try {
>               pageContext.forward(page);
>           } catch (Exception e) {
>               throw new JspException(e.toString());
>           }
>           return (SKIP_PAGE);
>       }
>
>    }
>
>Take a look at the example Mailserver application that comes with Struts.
>
>>-----Ursprungliche Nachricht-----
>>Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>>Gesendet: Dienstag, 20. November 2001 10:42
>>An: Struts Users Mailing List
>>Betreff: Want to check user is logged in every page server
>>
>>
>>Hi
>>
>>Everytime a page is served from my Struts application, I want to check 
>>to make sure the user is logged in.  If they are not then I want to send 
>>them to the login screen.  What is the best way to go about this using 
>>Struts?
>>
>>Cheers
>>
>>Tony



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to