You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Paul Joseph <pj...@gmail.com> on 2011/05/18 16:45:36 UTC

best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Hi there,

I have a Cocoon app that has numerous pages...I use Javascript 
(flowscript) to do the display and Java to do the "business logic."

In the Java layer, I have code to detect when the session expires and 
this works nicely and so I am able to maintain a count of currently 
logged in users.

Here is my request:  A customer asked that when their session expires, 
that they be shown the login page automatically.

Now I know when the session expires, but how do I show the Login page 
from within Java code?  They could be anywhere in the app so I presume I 
should directly have the Java code somehow display the Login page?

Pointers much appreciated.

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Posted by Paul Joseph <pj...@gmail.com>.
You are correct--I will go this route--I now realize that it is the 
right thing to do!

On 5/19/2011 6:57 AM, Andre Juffer wrote:
> On 19/05/11 13:38, Paul Joseph wrote:
>> HI Thorsten,
>>
>> Thank you much for your two suggestions.  I will proceed with your 
>> second course as it is very easy to do that given the way the app is 
>> written.
>
> Just like to add that the Auth approach basically works in the same 
> way. An action is available that will test whether or not a session is 
> expired. Everything is already written, and there is not much that you 
> need to do yourself (besides modifying the sitemap).
>
>>
>> best.
>> Paul
>>
>> On 5/19/2011 6:20 AM, Thorsten Scherler wrote:
>>> On Wed, 2011-05-18 at 10:45 -0400, Paul Joseph wrote:
>>>> Hi there,
>>>>
>>>> I have a Cocoon app that has numerous pages...I use Javascript
>>>> (flowscript) to do the display and Java to do the "business logic."
>>>>
>>>> In the Java layer, I have code to detect when the session expires and
>>>> this works nicely and so I am able to maintain a count of currently
>>>> logged in users.
>>>>
>>>> Here is my request:  A customer asked that when their session expires,
>>>> that they be shown the login page automatically.
>>>>
>>>> Now I know when the session expires, but how do I show the Login page
>>>> from within Java code?  They could be anywhere in the app so I 
>>>> presume I
>>>> should directly have the Java code somehow display the Login page?
>>>>
>>>> Pointers much appreciated.
>>> I reckon all pages are going through an action which test, whether the
>>> user is logged in, correct? If not how to you test whether the user is
>>> logged in and has the authority to see the page?
>>>
>>> The simplest I guess is to write your own action extending e.g.
>>> http://cocoon.apache.org/2.1/userdocs/optional/session-action.html 
>>> where
>>> you test for the session.
>>>
>>> You can use something like the following in your sitemap:
>>> <map:act type="session">
>>> <!-- session exists go on with generating USER page -->
>>> </map:act>
>>> <!-- session failed show login page-->
>>>
>>> Another route is to test it in your existing flow script and redirect
>>> from within that flow to the login page.
>>>
>>> if (YourJavaClass.validateSession(session)){
>>>   // session exists go on with generating USER page
>>> }else{
>>>   // session failed show login page
>>> }
>>>
>>> However that depends on your usecase which makes more sense.
>>>
>>> salu2
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Posted by Andre Juffer <an...@oulu.fi>.
On 19/05/11 13:38, Paul Joseph wrote:
> HI Thorsten,
>
> Thank you much for your two suggestions.  I will proceed with your 
> second course as it is very easy to do that given the way the app is 
> written.

Just like to add that the Auth approach basically works in the same way. 
An action is available that will test whether or not a session is 
expired. Everything is already written, and there is not much that you 
need to do yourself (besides modifying the sitemap).

>
> best.
> Paul
>
> On 5/19/2011 6:20 AM, Thorsten Scherler wrote:
>> On Wed, 2011-05-18 at 10:45 -0400, Paul Joseph wrote:
>>> Hi there,
>>>
>>> I have a Cocoon app that has numerous pages...I use Javascript
>>> (flowscript) to do the display and Java to do the "business logic."
>>>
>>> In the Java layer, I have code to detect when the session expires and
>>> this works nicely and so I am able to maintain a count of currently
>>> logged in users.
>>>
>>> Here is my request:  A customer asked that when their session expires,
>>> that they be shown the login page automatically.
>>>
>>> Now I know when the session expires, but how do I show the Login page
>>> from within Java code?  They could be anywhere in the app so I 
>>> presume I
>>> should directly have the Java code somehow display the Login page?
>>>
>>> Pointers much appreciated.
>> I reckon all pages are going through an action which test, whether the
>> user is logged in, correct? If not how to you test whether the user is
>> logged in and has the authority to see the page?
>>
>> The simplest I guess is to write your own action extending e.g.
>> http://cocoon.apache.org/2.1/userdocs/optional/session-action.html where
>> you test for the session.
>>
>> You can use something like the following in your sitemap:
>> <map:act type="session">
>> <!-- session exists go on with generating USER page -->
>> </map:act>
>> <!-- session failed show login page-->
>>
>> Another route is to test it in your existing flow script and redirect
>> from within that flow to the login page.
>>
>> if (YourJavaClass.validateSession(session)){
>>   // session exists go on with generating USER page
>> }else{
>>   // session failed show login page
>> }
>>
>> However that depends on your usecase which makes more sense.
>>
>> salu2
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
Biocenter Oulu and           | Fax: +358-8-553-1141
Department of Biochemistry   | Email: andre.juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
StrucBioCat                  | WWW: www.strucbiocat.oulu.fi
Triacle Biocomputing         | WWW: www.triacle-bc.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Posted by Paul Joseph <pj...@gmail.com>.
HI Thorsten,

Thank you much for your two suggestions.  I will proceed with your 
second course as it is very easy to do that given the way the app is 
written.

best.
Paul

On 5/19/2011 6:20 AM, Thorsten Scherler wrote:
> On Wed, 2011-05-18 at 10:45 -0400, Paul Joseph wrote:
>> Hi there,
>>
>> I have a Cocoon app that has numerous pages...I use Javascript
>> (flowscript) to do the display and Java to do the "business logic."
>>
>> In the Java layer, I have code to detect when the session expires and
>> this works nicely and so I am able to maintain a count of currently
>> logged in users.
>>
>> Here is my request:  A customer asked that when their session expires,
>> that they be shown the login page automatically.
>>
>> Now I know when the session expires, but how do I show the Login page
>> from within Java code?  They could be anywhere in the app so I presume I
>> should directly have the Java code somehow display the Login page?
>>
>> Pointers much appreciated.
> I reckon all pages are going through an action which test, whether the
> user is logged in, correct? If not how to you test whether the user is
> logged in and has the authority to see the page?
>
> The simplest I guess is to write your own action extending e.g.
> http://cocoon.apache.org/2.1/userdocs/optional/session-action.html where
> you test for the session.
>
> You can use something like the following in your sitemap:
> <map:act type="session">
>    <!-- session exists go on with generating USER page -->
> </map:act>
> <!-- session failed show login page-->
>
> Another route is to test it in your existing flow script and redirect
> from within that flow to the login page.
>
> if (YourJavaClass.validateSession(session)){
>   // session exists go on with generating USER page
> }else{
>   // session failed show login page
> }
>
> However that depends on your usecase which makes more sense.
>
> salu2

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Posted by Thorsten Scherler <sc...@gmail.com>.
On Wed, 2011-05-18 at 10:45 -0400, Paul Joseph wrote:
> Hi there,
> 
> I have a Cocoon app that has numerous pages...I use Javascript 
> (flowscript) to do the display and Java to do the "business logic."
> 
> In the Java layer, I have code to detect when the session expires and 
> this works nicely and so I am able to maintain a count of currently 
> logged in users.
> 
> Here is my request:  A customer asked that when their session expires, 
> that they be shown the login page automatically.
> 
> Now I know when the session expires, but how do I show the Login page 
> from within Java code?  They could be anywhere in the app so I presume I 
> should directly have the Java code somehow display the Login page?
> 
> Pointers much appreciated.

I reckon all pages are going through an action which test, whether the
user is logged in, correct? If not how to you test whether the user is
logged in and has the authority to see the page?

The simplest I guess is to write your own action extending e.g.
http://cocoon.apache.org/2.1/userdocs/optional/session-action.html where
you test for the session.

You can use something like the following in your sitemap:
<map:act type="session">
  <!-- session exists go on with generating USER page -->
</map:act>
<!-- session failed show login page-->

Another route is to test it in your existing flow script and redirect 
from within that flow to the login page.

if (YourJavaClass.validateSession(session)){
 // session exists go on with generating USER page
}else{
 // session failed show login page
}

However that depends on your usecase which makes more sense. 

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Posted by Andre Juffer <aj...@cc.oulu.fi>.
On 05/18/2011 07:18 PM, Paul Joseph wrote:
> I think I should use this: http://wiki.apache.org/cocoon/ErrorHandling

Not sure, never used it.

>
> On 5/18/2011 11:22 AM, Andre Juffer wrote:
>> Paul,
>>
>> you could use Auth:
>>
>> http://cocoon.apache.org/2.2/blocks/auth/1.0/1236_1_1.html
>>
>> I have used this with 2.2 and does seem to work fine.
>>
>> One can test in flowscript whether or not a request is send while the
>> session was expired/closed. Testing whether or not the session expired
>> does not belong in the domain/business layer (IMHO). The test in
>> flowscript is done before the request is forwarded to the business
>> layer. If the session is expired, you simply redirect the request to a
>> login page, so it never reaches the business layer.
>>
>> best regards,
>> Andre
>>
>> On 05/18/2011 05:45 PM, Paul Joseph wrote:
>>> Hi there,
>>>
>>> I have a Cocoon app that has numerous pages...I use Javascript
>>> (flowscript) to do the display and Java to do the "business logic."
>>>
>>> In the Java layer, I have code to detect when the session expires and
>>> this works nicely and so I am able to maintain a count of currently
>>> logged in users.
>>>
>>> Here is my request: A customer asked that when their session expires,
>>> that they be shown the login page automatically.
>>>
>>> Now I know when the session expires, but how do I show the Login page
>>> from within Java code? They could be anywhere in the app so I presume I
>>> should directly have the Java code somehow display the Login page?
>>>
>>> Pointers much appreciated.
>>>
>>> Paul
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
Biocenter Oulu and           | Fax: +358-8-553-1141
Department of Biochemistry   | Email: andre.juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat                   | WWW: www.strubiocat.oulu.fi
NordProt                     | WWW: www.nordprot.org
Triacle Biocomputing         | WWW: www.triacle-bc.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Posted by Paul Joseph <pj...@gmail.com>.
I think I should use this: http://wiki.apache.org/cocoon/ErrorHandling

On 5/18/2011 11:22 AM, Andre Juffer wrote:
> Paul,
>
> you could use Auth:
>
> http://cocoon.apache.org/2.2/blocks/auth/1.0/1236_1_1.html
>
> I have used this with 2.2 and does seem to work fine.
>
> One can test in flowscript whether or not a request is send while the 
> session was expired/closed. Testing whether or not the session expired 
> does not belong in the domain/business layer (IMHO). The test in 
> flowscript is done before the request is forwarded to the business 
> layer. If the session is expired, you simply redirect the request to a 
> login page, so it never reaches the business layer.
>
> best regards,
> Andre
>
> On 05/18/2011 05:45 PM, Paul Joseph wrote:
>> Hi there,
>>
>> I have a Cocoon app that has numerous pages...I use Javascript
>> (flowscript) to do the display and Java to do the "business logic."
>>
>> In the Java layer, I have code to detect when the session expires and
>> this works nicely and so I am able to maintain a count of currently
>> logged in users.
>>
>> Here is my request: A customer asked that when their session expires,
>> that they be shown the login page automatically.
>>
>> Now I know when the session expires, but how do I show the Login page
>> from within Java code? They could be anywhere in the app so I presume I
>> should directly have the Java code somehow display the Login page?
>>
>> Pointers much appreciated.
>>
>> Paul
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Posted by Paul Joseph <pj...@gmail.com>.
Hi Andre,

Thank you kindly for your reply.

I guess I could implement cocoon-auth, but am a bit reluctant to at this 
point as it looks like a substantial change.

I figure, I know already when the server expires the session via 
HttpSessionBindingListener and have a method around this already

...so all I need is to tack on one line (hopefully) that will simply 
send the user to the login page...

brgds
Paul

On 5/18/2011 11:22 AM, Andre Juffer wrote:
> Paul,
>
> you could use Auth:
>
> http://cocoon.apache.org/2.2/blocks/auth/1.0/1236_1_1.html
>
> I have used this with 2.2 and does seem to work fine.
>
> One can test in flowscript whether or not a request is send while the 
> session was expired/closed. Testing whether or not the session expired 
> does not belong in the domain/business layer (IMHO). The test in 
> flowscript is done before the request is forwarded to the business 
> layer. If the session is expired, you simply redirect the request to a 
> login page, so it never reaches the business layer.
>
> best regards,
> Andre
>
> On 05/18/2011 05:45 PM, Paul Joseph wrote:
>> Hi there,
>>
>> I have a Cocoon app that has numerous pages...I use Javascript
>> (flowscript) to do the display and Java to do the "business logic."
>>
>> In the Java layer, I have code to detect when the session expires and
>> this works nicely and so I am able to maintain a count of currently
>> logged in users.
>>
>> Here is my request: A customer asked that when their session expires,
>> that they be shown the login page automatically.
>>
>> Now I know when the session expires, but how do I show the Login page
>> from within Java code? They could be anywhere in the app so I presume I
>> should directly have the Java code somehow display the Login page?
>>
>> Pointers much appreciated.
>>
>> Paul
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: best way to show login page when session expires? (Javascript/Java based Cocoon app.)

Posted by Andre Juffer <aj...@cc.oulu.fi>.
Paul,

you could use Auth:

http://cocoon.apache.org/2.2/blocks/auth/1.0/1236_1_1.html

I have used this with 2.2 and does seem to work fine.

One can test in flowscript whether or not a request is send while the 
session was expired/closed. Testing whether or not the session expired 
does not belong in the domain/business layer (IMHO). The test in 
flowscript is done before the request is forwarded to the business 
layer. If the session is expired, you simply redirect the request to a 
login page, so it never reaches the business layer.

best regards,
Andre

On 05/18/2011 05:45 PM, Paul Joseph wrote:
> Hi there,
>
> I have a Cocoon app that has numerous pages...I use Javascript
> (flowscript) to do the display and Java to do the "business logic."
>
> In the Java layer, I have code to detect when the session expires and
> this works nicely and so I am able to maintain a count of currently
> logged in users.
>
> Here is my request: A customer asked that when their session expires,
> that they be shown the login page automatically.
>
> Now I know when the session expires, but how do I show the Login page
> from within Java code? They could be anywhere in the app so I presume I
> should directly have the Java code somehow display the Login page?
>
> Pointers much appreciated.
>
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
Biocenter Oulu and           | Fax: +358-8-553-1141
Department of Biochemistry   | Email: andre.juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat                   | WWW: www.strubiocat.oulu.fi
NordProt                     | WWW: www.nordprot.org
Triacle Biocomputing         | WWW: www.triacle-bc.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org