views:

494

answers:

5

Hi,

I am implementing jsr 186 portlets, with some servlets to the mix to implement some ajax. The problem is if I only make AJAX calls for some time, I lose the session. Strangely, keeping alive the servlet session does not prevent the portlet session from timing out.

Is there a way I can keep the session alive from within my servlets, on the server side?

FWIW I'm using spring and spring mvc/portlet.

Thanks, Miguel Ping

A: 

I got the same problem. Any body has answer?

A: 

i would also be interested in a possible solution? i cant believe there is no cure for this..

knrr
A: 

I implemented it using a javascript timer that kept polling a portlet url. The portlet url was generated beforehadn so it was accessible in javascript.

Miguel Ping
A: 

hey miguel,

thanks for your answer but i dont get it really.. :(

does your url polling induce a post on the portal? wouldnt that be equal to a session timeout?

my problem is, when i heavily use an ajax framework, like ZK for example, and do everything with dom manipulation and no posts to the portal - after a while, because of only relying to AJAX calls and no JSR168 lifecycle, the session will timeout and everything the user has entered (without pressing the submit button) will be lost.

would your solution make a difference?

thanks for your time,

fabian

knrr
Yes, I am posting to a Portal URL. The trick part was generating a Portal URL (eg: renderURL) and make it accessible to the AJAX part. After that, it's just a matter of polling that url once in a while.I don't think it needs to be a POST in order to keep the session alive, so I made a GET instead.
Miguel Ping
A: 

I had the same problem. (Using OpenPortal Portlet Container)

As I know there is two different sessions, 1- portlet session, 2- Container session.

I created a simple portlet and made request to the portlet with ajax periodically from container. However, session times out. My code fraction is here:

<%
    int per=15000; //ms
    String sessionExtenderPath = "http://portal.abc.com.tr:8080/SessionExtend/SessionExtend";
    //This is a portlet which includes servlet that returns a simple string.
%>

<script>
    periyod=100;

    function invokeRequest(){
     $.get("< %=sessionExtenderPath% >", function(data) {
      alert(1);
     });
    }
    window.setInterval("invokeRequest()",periyod);
</script>

I have solved my problem by requesting container page (wihout defining a channel for a portlet).

Thanks for edit.

MrNoName