You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Frank W. Zammetti" <fz...@omnytex.com> on 2005/05/13 15:17:49 UTC
Re: Sessions and keep-alives
Well, I would want to keep the apps isolated as much as possible, so I
would do something like this...
(1) When App A opens App B, at the same time, it calls a function of its
own that sets a flag in session to indicate that App B is open.
(2) On every page of App A I would have a Javascript function that is
called as a result of a timer started onLoad. This function would be
something like:
function keepAlive() {
try {
if (window.XMLHttpRequest){
ajaxXHR = new XMLHttpRequest();
} else {
ajaxXHR = new ActiveXObject('Microsoft.XMLHTTP');
}
ajaxXHR.open("get", "myKeepAliveAction.do", true);
ajaxXHR.send(null);
} catch(e) {
alert(e.message);
}
}
(3) myKeepAliveAction would do basically nothing, just return null for the
forward.
(4) Be sure to only set the timer onLoad when the flag is set in session
indicating app B is open.
So, what this will do is that when App B is opened, App A would fire this
AJAX request to myKeepAliveAction (be sure to set the timer interval to
something less than App A's timeout period!). That should keep App A from
timing out and you won't have to worry about refreshing any page or
anything.
The only problem I see is what do you do when App B closes? I presume
you'd want the timeout in App A to take effect again, but I don't see a
foolproof way to do that.
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
On Fri, May 13, 2005 1:47 am, Patrick Lacson said:
> hi Frank,
>
> you're the second person who suggested making an ajax call.. partly
> because its probably a cleaner approach.
>
> do you have an example of how i can use ajax from webapp B to call
> webapp A in some interval period?
>
> thanks much.
>
>
> On 5/12/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> If you can use Javascript (and can require it), what you could do is set
>> a timer in app B's onLoad event to call a Javascript function in app A
>> from app B (parent.myFunction();)... This function could refresh
>> whatever the current page is in some interval less than your timeout
>> period. You'll have to ensure all pages of app A have that refresh
>> function in page-scope, and that all pages in B set that timer and make
>> the call.
>>
>> If a full-page refresh isn't feasible, you can make an AJAX call to app
>> A that does really nothing, but that should be enough to keep the
>> session from timing out.
>>
>> Does that all make sense? (I'm not sure I described it well)
>>
>> Frank W. Zammetti
>>
>> -----Original Message-----
>> From: "Patrick Lacson"<pl...@gmail.com>
>> Sent: 5/13/05 12:56:43 AM
>> To: "Tomcat Users List"<to...@jakarta.apache.org>
>> Subject: Re: Sessions and keep-alives
>> I've considered iframes, but unfortunately not an option for us.
>>
>> >From what I understand AJAX can make async calls to the HTTP server
>> from the webapplication only, not on behalf of another. So if the
>> popup application is webapp B, and the parent webapp A, how can I
>> call
>> the webapp A server from webapp B for the keep-alive?
>>
>> On 5/12/05, Tim Funk <fu...@joedog.org> wrote:
>> > The simplest kludge is an iframe that is "hidden" and uses a META
>> refresh.
>> >
>> > Or look at using ajax.
>> >
>> > -Tim
>> >
>> > Patrick Lacson wrote:
>> >
>> > > hi All!
>> > >
>> > > I'm involved in a project that integrates two disparate web
>> > > applications: webapp A is using WebSphere and webapp B is using
>> > > Tomcat.
>> > >
>> > > The integration involves Single Sign On, with webapp A being the
>> > > primary webapp from which webapp B is launched. webapp B is
>> launched
>> > > as a popup-window.
>> > >
>> > > My question is: how can i ensure that while the user is working
>> on the
>> > > webapp B popup, the parent window webapp A, does not time-out?
>> > >
>> > > Thanks in advance!
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail:
>> tomcat-user-help@jakarta.apache.org
>> >
>> >
>>
>> --
>> Patrick
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>> [Message truncated. Tap Edit->Mark for Download to get remaining
>> portion.]
>>
>>
>
>
> --
> Patrick
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Sessions and keep-alives
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I was wondering if you were going to say that :) That prompts me to ask,
why not simply not have a timeout in App A at all?
I mean, if opening App B is supposed to, in a sense, stop App A from ever
timing out, and if closing App B doesn't necessarily somehow allow App A
to time out again, it sounds like App A timing out is something you could
do without period.
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
On Fri, May 13, 2005 12:01 pm, Patrick Lacson said:
> Thanks for the code Frank, I'll give this a try.
>
>> The only problem I see is what do you do when App B closes? I presume
>> you'd want the timeout in App A to take effect again, but I don't see a
>> foolproof way to do that.
>>
>
> If webapp B closes, I don't neccessarily want webapp A to timeout.
> The primary application is webapp A and webapp B offers small
> functionality.
>
> Thanks
>
> -Patrick
>
> On 5/13/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> Well, I would want to keep the apps isolated as much as possible, so I
>> would do something like this...
>>
>> (1) When App A opens App B, at the same time, it calls a function of its
>> own that sets a flag in session to indicate that App B is open.
>>
>> (2) On every page of App A I would have a Javascript function that is
>> called as a result of a timer started onLoad. This function would be
>> something like:
>>
>> function keepAlive() {
>> try {
>> if (window.XMLHttpRequest){
>> ajaxXHR = new XMLHttpRequest();
>> } else {
>> ajaxXHR = new ActiveXObject('Microsoft.XMLHTTP');
>> }
>> ajaxXHR.open("get", "myKeepAliveAction.do", true);
>> ajaxXHR.send(null);
>> } catch(e) {
>> alert(e.message);
>> }
>> }
>>
>> (3) myKeepAliveAction would do basically nothing, just return null for
>> the
>> forward.
>>
>> (4) Be sure to only set the timer onLoad when the flag is set in session
>> indicating app B is open.
>>
>> So, what this will do is that when App B is opened, App A would fire
>> this
>> AJAX request to myKeepAliveAction (be sure to set the timer interval to
>> something less than App A's timeout period!). That should keep App A
>> from
>> timing out and you won't have to worry about refreshing any page or
>> anything.
>>
>> The only problem I see is what do you do when App B closes? I presume
>> you'd want the timeout in App A to take effect again, but I don't see a
>> foolproof way to do that.
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>>
>> On Fri, May 13, 2005 1:47 am, Patrick Lacson said:
>> > hi Frank,
>> >
>> > you're the second person who suggested making an ajax call.. partly
>> > because its probably a cleaner approach.
>> >
>> > do you have an example of how i can use ajax from webapp B to call
>> > webapp A in some interval period?
>> >
>> > thanks much.
>> >
>> >
>> > On 5/12/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>> >> If you can use Javascript (and can require it), what you could do is
>> set
>> >> a timer in app B's onLoad event to call a Javascript function in app
>> A
>> >> from app B (parent.myFunction();)... This function could refresh
>> >> whatever the current page is in some interval less than your timeout
>> >> period. You'll have to ensure all pages of app A have that refresh
>> >> function in page-scope, and that all pages in B set that timer and
>> make
>> >> the call.
>> >>
>> >> If a full-page refresh isn't feasible, you can make an AJAX call to
>> app
>> >> A that does really nothing, but that should be enough to keep the
>> >> session from timing out.
>> >>
>> >> Does that all make sense? (I'm not sure I described it well)
>> >>
>> >> Frank W. Zammetti
>> >>
>> >> -----Original Message-----
>> >> From: "Patrick Lacson"<pl...@gmail.com>
>> >> Sent: 5/13/05 12:56:43 AM
>> >> To: "Tomcat Users List"<to...@jakarta.apache.org>
>> >> Subject: Re: Sessions and keep-alives
>> >> I've considered iframes, but unfortunately not an option for
>> us.
>> >>
>> >> >From what I understand AJAX can make async calls to the HTTP
>> server
>> >> from the webapplication only, not on behalf of another. So if
>> the
>> >> popup application is webapp B, and the parent webapp A, how can I
>> >> call
>> >> the webapp A server from webapp B for the keep-alive?
>> >>
>> >> On 5/12/05, Tim Funk <fu...@joedog.org> wrote:
>> >> > The simplest kludge is an iframe that is "hidden" and uses a
>> META
>> >> refresh.
>> >> >
>> >> > Or look at using ajax.
>> >> >
>> >> > -Tim
>> >> >
>> >> > Patrick Lacson wrote:
>> >> >
>> >> > > hi All!
>> >> > >
>> >> > > I'm involved in a project that integrates two disparate web
>> >> > > applications: webapp A is using WebSphere and webapp B is
>> using
>> >> > > Tomcat.
>> >> > >
>> >> > > The integration involves Single Sign On, with webapp A being
>> the
>> >> > > primary webapp from which webapp B is launched. webapp B is
>> >> launched
>> >> > > as a popup-window.
>> >> > >
>> >> > > My question is: how can i ensure that while the user is
>> working
>> >> on the
>> >> > > webapp B popup, the parent window webapp A, does not
>> time-out?
>> >> > >
>> >> > > Thanks in advance!
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail:
>> tomcat-user-unsubscribe@jakarta.apache.org
>> >> > For additional commands, e-mail:
>> >> tomcat-user-help@jakarta.apache.org
>> >> >
>> >> >
>> >>
>> >> --
>> >> Patrick
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail:
>> tomcat-user-unsubscribe@jakarta.apache.org
>> >> For additional commands, e-mail:
>> tomcat-user-help@jakarta.apache.org
>> >>
>> >> [Message truncated. Tap Edit->Mark for Download to get remaining
>> >> portion.]
>> >>
>> >>
>> >
>> >
>> > --
>> > Patrick
>> >
>>
>
>
> --
> Patrick
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org