Skip to Content

Portal user idle timeout using dialog windows – Client side solution

Warning MessageWarningLog Off Message


As per the SAP Note: 982982 there is no standard solution in SAP Portal to Logoff the Portal due to user inactivity. Hence people have been using client side solution to overcome this. Upto certain extent this functionality built using Javascript has been useful. With reference to the Portal timeout solution posted by Arnaud Leymet, this post is an enhancement of the Portal user idle timeout solution.

Background of previous Solution :

If user is idle, then the Portal displays a warning message to the user after a certain period (warning period). In the duration between warning period and actual timeout period, if user intervens and clicks on the Warning message, then Portal timer is updated. Else the Portal still remains idle waiting for user intervention. Hence the actual timeout of the application is happenning only after user intervention. Even if the user has not seen the application for n hours the portal would not have logged off.

Hence to overcome this issue, in place of an alert I have used a dialog window prompting the user to activate the portal and will be displayed for few minutes (timeout period – warning period) after which it closes automatically and logs off the portal. Before logging off it opens a new window informing the user about the session termination due to inactivity. The code has been modified for achieving the same.


Open Mashead PAR file through NWDS.

Create a JS page by name customtimeout.js under scripts folder in the project directory and include the same in Headerivew.jsp page.

Add the below code in customtimeout.js



For opening a pop up dialog window in Internet Explorer browser after the warning period, create a JSP page by name IEDialog.JSP and add the below code in it .


The Portal session will expire in 5 minute(s). Please click [Continue/Logoff] to Re-activate/End the session.


For opening a pop up dialog window in other browsers after the warning period, create a JSP page by name FFDialog.JSP and add the below code in it .


Your session will expire in 5 minute(s). Please click [Continue/Logoff] to Re-activate/End the session.

To display a Logoff message after Portal Log off, create a JSP page by name LogoffMessage add the below code in it . 

The Log off Message is displayed, so that user can identify that its a force log off due to session inactivity.  The HTML code for the same is given below.


The Portal session has been terminated due to inactivity. Please login again.


Add the below code towards the end of HeaderiView.jsp

(No change done in this page compared to previous)



Note: The Idle warn delay & kick delay values can be changed as per the requirement in

customTimeoutHandler(25, 30) in HeaderiView.jsp.


After being idle on the portal for 25 minutes , you should obtain a popup like the following:

Dialog Window:


Log off message after timeout:


It worked for me. Hope you’ll find it useful.

You must be Logged on to comment or reply to a post.
    • Hi,

      Thanks for informing that. I had problems during posting it, so may be by mistake. 🙂
      Anyways, I have updated the code in HeaderiView.jsp. Just add the given JS code at the end of the page.


      • Hi Santhosh,

        I am confused at the part on customtimeout.js and HeaderView.jsp.

        1.  What do you add into HeaderView.jsp?
        2.  Do you create a new js file call customtimeout.js and include the script into HeaderView.jsp? How do you do it?


      • Hi Santhosh,

        I am new at this. I don’t understand about the part on customtimeout.js and headeriview.jsp.

        1. I got an error when I opened customtimeout.js by double clicking it:
        line: 14
        char: 7
        Error: Expected identifier, string or number
        Code: 800A0404
        Source: Microsoft JScript compilation error

        2. Besides adding the below code at the end of headeriview.jsp, what else do I need to include in headeriview.jsp relative to customtimeout.js?

        var timeout_h = customTimeoutHandler(10, 15);
        function pop() { timeout_h.updateTimer(); }
        EPCM.subscribeEvent(“urn:com.sapportals:navigation”, “Navigate”, pop);
        //EPCM.subscribeEvent(“”, “myEvent”, pop);


        • Hi,

          Sorry for the delayed response as I was not getting any updates regarding this post.

          The solution for your issue is updated in the above thread.


  • Hi,

    In the customtimeout.js the line:

    EventID = window.showModalDialog(“IEDialog.jsp”,”Dialog”,”dialogWidth:500px;dialogHeight:130px;toolbar:no;directories:no;status:no;menubar:no;scrollbars:no;resizable:no;modal:yes”);

    presents a popup with a runtime error as you don’t seem to be able to link directly to a jsp page. Please correct me if I’m wrong!?

    • Hi,

      If you can notice the code, the modal dialog window sends back the data to the parent page through Event Id.

      if(EventID != null && EventID == ‘C’)
      { timeout_h.updateTimer();

      Now notice Dialog page code.
      function callBack(EventID) {
      window.returnValue = EventID;

      The values are explicitly sent back for further action. Hope you understood this now.


      • Hi,<br/><br/>Thanks for the reply. I think you misunderstood my question. I have included the customtimeout.js in HeaderIview.jsp using:<br/><br/><% String jsresourcepath = componentRequest.getWebResourcePath()+”/scripts/customtimeout.js”; %><br/><script type=”text/javascript” src=”<%=jsresourcepath%>”></script><br/><br/>The timeout works as expected and I get a popup with a portal error rather than the IEDialog.jsp. I believe its because the line in my 1st post doesn’t have a context when trying to find IEDialog.jsp. Can you advise?

        • Hi,
          Sorry for the delayed response as I was not getting any updates reagrding this post.

          For your query, mention the complete path of the JSP page instead of IEDialog.JSP in your code.

          Ex: “/irj/portalapps/”, ….
          “/irj/portalapps/”, ….

          Refer, the code snippet again.


  • This is fine if you navigate through tabs and the timeout resets the inactive time but if you are working within a web dynpro application or in KM, the timeout kicks in and logs you off.
    • This post is a workaround for substituting a lack of standard functionality & not a flaw. For managing Webdynpro timers, there are standard timeout configuration parameters in configtool. To manage this at the application level, try using WebDynpro handlers along with EPCM listeners. I am sure there are other listeners for KM apps too.
  • i followed the steps given by you.i created a new par file with all modifications as you have trying to create an iview,but now iam confused with which component do i need to create the iview.there are some 6 components.can u please guide me on creating the iview,assigning to the page and so on.
    • Hi,
      Sorry for the delayed response as I was not getting any updates regarding this post.

      Instead of creating a new PAR, you should do the above mentioned modifications in the standard Masthead PAR file to achieve this functionality.


  • The IEDialog.jsp is not found when invoked,so getting an 404 error wkindow insteadof the pop up.

    I have kept the customtimeout.js under the dist/scripts folder and the jsp is in PORTAL-INF/jsp folder.Please let me know if there is anything i need to change.Its a bit urgent ,looking forward to you response


  • Hi santhosh,

    I have mentioned each and every thing through this blog. but i didn’t get dailog window. i am getting Error on page at bottom of the browser.

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; CMNTDF; .NET4.0C; .NET4.0E)
    Timestamp: Thu, 7 Apr 2011 11:42:16 UTC

    Message: Expected identifier, string or number
    Line: 14
    Char: 7
    Code: 0
    URI: http://…./irj/portalapps/

    Message: Object expected
    Line: 501
    Char: 1
    Code: 0

    please suggest ASAP.


  • Hi Santosh .

    I am trying to incorporate your code in AFP Masthead.
    As soon as I log into portal I get  script error
    Message: Object doesn’t support this property or method
    Line: 130
    Char: 1
    Code: 0

    The script error which it points to “ logoff() ;” method in customtimeout.js.

    After running the script in few min, IEDialog.jsp page opens with a script error
    ” black is undefined in line 28″

    Again after running the script with errors and clicking Logoff button I get the below error

    Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; GTB7.0; xs-BQhVyaEXOFs;ksVaLy; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
    Timestamp: Fri, 29 Apr 2011 18:34:20 UTC

    Message: Object doesn’t support this property or method
    Line: 130
    Char: 1
    Code: 0

    which points to method “logoff()”; in customtimeout.js “.

    The LogoffMessage.jsp opens stating its comments.

    But the portal is not closed or getting timed out in any of the about occurance. Only the JSPs  are opening.Kindly suggest so that it would be of greatest help. 

    Thanks in Advance.

    • Prasanna,

      I found an extra curley bracket at the end of the script.  When I took it out, it started working.  How did you add the “IEDialog.jsp” page to the par project?  The ide will not let me add a jsp, won’t let me select a folder.  I can add a jsp in other projects.



    • Hello All,

      I believe, there were typo errors which might have happened while I had reposted the code snippets along with some improvements in the application for multiple browser support. I have corrected the same & it should work now.

      If you come across any other typo errors, please notify the same as I had difficulty posting the snippets through this tool.