Hello Antony,

        I extend the ActionServlet and Write some code to test if the
user is logged and if He has permission to acess a page.

        It's very flexibile because is not only a test of login or not
login. I can test, for example, if user XYZ has permission to acess some
URL after He is logged in.



Régis Melo
SoftSite Tecnologia



-----Mensagem original-----
De: Antony Stace [mailto:[EMAIL PROTECTED]] 
Enviada em: domingo, 27 de janeiro de 2002 23:25
Para: [EMAIL PROTECTED]
Assunto: 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