How to handle session expiration in ATG

Hi,
We have a requirement wherein we have to redirect the user to a specific jsp when his session is expired. For example if a guest user is in cart page and is idle for more than 30 min he should be redirected to session expired page. We are using Apache web server and Jboss app server. Following are the ways i tried
1. In Apache/conf/extra/httpd-vhosts.conf, I have set ErrorDocument 409 to session expired jsp - This is failed because jsp is not a static content and only static contents will be present in webserver. If it would have been a simple html (static) then this method would have worked fine I believe.
2. In cart page I have set the sessionExpirationURL of cartformhandler to appropriate jsp, checkForValidSession to true, CheckSessionExpiration.expirationURL to same session expired jsp. I am not sure why this is not working.
Please let me know the best way to handle this situation. Any suggestions would be appreciated.
Regards,
Avinash

When user clicks any link on your page after session expired then you can redirect him to login page through your formhandler if a handleX() method was invoked by the request or you can use a filter which can check for something like profile.isTransient(). You can then redirect to the login page from your filter keeping a parameter of the original url to be used as login success url so that after login you can again redirect to the page that user originally intended to see.
For detecting user idleness in browser, here is one of the possible approach using javascript by implementing a document level keyboard/mouse listener to detect user interaction in your page:
<script type="text/javascript">
    var t;
    window.onload = resetTimer;
    document.onmousemove = resetTimer;
    document.onkeypress = resetTimer;
    function handleIdleTimedOut() {
        //alert("You are now logged out.");
        window.location.href = 'logout.jsp';
    function resetTimer() {
        clearTimeout(t);
        var timeoutPeriod = 1000 * 60 * 5;  //5 minutes       
        t = setTimeout(handleIdleTimedOut, timeoutPeriod);
</script>Apart from this, you may also want to take a look at reverse ajax to send the timed out kind of notification to the browser with the help of a HttpSessionListener:
http://directwebremoting.org/dwr/documentation/reverse-ajax/index.html
Hope this helps.
Edited by: Nitin Khare on Aug 23, 2012 12:15 AM

Similar Messages

  • How to maintain session-expiration details..?

    Where i have to include session-expiration time in ATG (i.e how to fire an session-expiration event) ..
    Thanks in Advance,
    Vishnu & Nithin Kayithi

    you might want to check this link.
    http://atgkid.blogspot.com/2011/11/atg-session-management.html

  • How to handle sessions with two severs on one machine?

    All,
    I am having a problem with session cookies being overwritten when I host two apps on one machine running WebLogic 8.1 The apps are http://myserver:7300/app1 and http://myserver:7400/app2, and each runs in its own server.
    Users will often access both apps at once, in two browser windows. If the windows are different threads in the same process, the sessions collide. For Internet Explorer, this isn't usually a problem since clicking on the shortcut multiple times launches different processes by default. Some browsers (Firefox, etc.) won't let you have two windows under different processes. Attempts to launch a second window 'detect' the existing process and appear to spawn a new thread. When this happens there appears to be no way for the users to use both apps at once.
    I know this is happening because of the way session cookies are stored in the browser process' memory. The session cookies appear to me to be 'keyed' by the host name or ip address of the server. Does anyone know of a setting in WebLogic so that this 'key' includes the port or context root? Is this even something which can be controlled on the server side?
    Thanks for any help,
    Brian

    Not quite sure what your intent is, but if you want to avoid a clash how
    about giving each application a different default session cookie name.

  • How to handle session-timeout in producer-consumer(wsrp) environment.

    Hi
    We are using weblogic portal 9.2 in federated environment (wsrp) .
    We have one consumer Ear and some producer Ear .
    we want if session is time out ,then user should direct to some default page .
    For that we are firing event in Base Exception handler where we caught all exceptions.
    that event is listen by consumer side ,(when session time out producer raise event).
    event is fired , every thing looks fine but we are not able to redirect page from producer to consumer (which should not be happen )
    I think we are doing something wrong .
    Any suggestion/ guidance will help us lot
    thanks in advance

    Hello,
    Probably the easiest way for you to get the behaviour you want would be to put a event handler on a .portlet file (on the consumer) that lives on the page you want to activate if the producer session has timed out. For example:
    <netuix:handleCustomEvent event="eventNameComingFromProducer" eventLabel="sessionTimeoutPageActivation">
    <netuix:activatePage/>
    </netuix:handleCustomEvent>
    When your producer portlet sends an event "eventNameComingFromProducer" the portlet on the page you want to activate will pick it up and automatically activate the page.
    Kevin

  • How to handle sessions in struts

    i have created a session. even after logout its not destroying the session.
    //here i am creating session object
    public ActionForward setupdate(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) {
              ApplicationForm applicationForm = (ApplicationForm) form;
              String eid=applicationForm.getEid();
              HttpSession session = request.getSession(true);
              try {
                   PrintWriter out=response.getWriter();
                   if( applicationForm.getEid() != null && ! applicationForm.getEid().equals("") )
              session.setAttribute("User",applicationForm.getEid());
              System.out.println("you are logged in");
              out.println("you are logged in");
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
                        return mapping.findForward("update") ;
    //this my logout method
    public ActionForward logout(ActionMapping mapping,ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
              { ApplicationForm applicationForm = (ApplicationForm) form;
              //PrintWriter out=response.getWriter();
              HttpSession session=request.getSession(false);
              try {
                   PrintWriter out=response.getWriter();
                   if(session == null)
                        out.println("FIRST YOU NEED TO LOGIN");
                        System.out.println("FIRST YOU NEED TO LOGIN");
                   else
                        out.println("THANKS FOR USING OUR APPLICATION!!!!");
                        System.out.println("THANKS FOR USING OUR APPLICATION!!!!");
                        out.println("id---->"+session.getId());
                        session.getAttribute("User");
                        session.invalidate();
              } catch (IOException e) {
                   e.printStackTrace();
              return mapping.findForward("logout");}
    please me help me out.
    saju

    You might want to check the API on that method again.
    public void setMaxInactiveInterval(int interval)
    Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.
    With regards to tracking who is logged on there are two issues.
    1 - tracking who is logged on
    - I would probably use a Map in application scope. Database table will also work. Its the same idea. When they log in, mark their presence. When they logout/expire then remove it.
    2 - responding to login/logout/expire events.
    - I would recommend using a HttpSessionBindingListener
    public class User implements HttpSessionBindingListener {
      String name;
      public User(String name){
        this.name = name;
      public void valueBound(HttpSessionBindingEvent event){
        // record login of this user
        if (userLoggedIn(this)){
          //user already logged in - throw an error and invalidate session
        else{
          // mark user as logged in.
      public void valueUnbound(HttpSessionBindingEvent event){
        // record logout of this user.
    }The code is invoked by the object being added/removed from a session.
    User user = new User("Bob");
    session.setAttribute("user", user);Cheers,
    evnafets

  • Handle Session Expire in JSP

    Dear Friends
    I am new to JSP. When the session expireses let us take that i am in the xxxx.jsp page when i refresh the page it goes to login page. After success fully login is should go to the xxxx.jsp page tell me how to do that. I am waiting for you replies. It is very urgent please to help me.
    with regards
    selva

    Dear Friend
    Thank you for your reply. But being a novice i could not understand what you have said. Can you give more explanation or Can you give me some samples which full fills my requirements. I hope that would be a greate help form me. Realy i very great full for your reply an waiting for another reply.
    with regards
    selva

  • How to handle IPortalComponent Session in Dynpage

    Hi Guys,
    I am using IPortalComponentSession object to hold the bean instances. Evey thing is working, if page is not idle for more than 20 min. If I access the page when the page is idle for more than 20 min, it is throwing Null pointer exception. This is because IPortal
    ComponentSession scope gets lost and couldn't get the bean object.
    Is there any parameter available to set the Global Portal Sesssion time to IPortalComponent Session, such that when portal session expires IPortalComponent Session expires automatically.
    Is there any property exists in portalapp.xml file or iview.
    Thanks in Advance
    Chinna.

    Hi All,
    As I said, when ever the component session expires Null pointer exception is showing. Hence I am catching the NullPointer exception and then reloading the page again. It is working in frontend without any issues.
    But in the error log monitor(nwa) I can see the below error when reloading the page after component session expires.
    Cannot change transaction isolation during distributed transaction and when the connection is shared. DataSource name: "PRODB2
    As per my knowledge I understood that this is happening beacuse application is trying to recreate a new connection pool while one pool instance is alive.
    If this is correct can any one tell me how to destory the pool of current session when reloading the page.
    Thanks in Advance,
    Chinna.

  • How to Handle user Session in JSP

    Help me,
    How to handle user session in JSP.......

    Prakash_Pune wrote:
    tell me some Debugging tech. so i can overcome from my problem.....Do you use an IDE? Any IDE ships with a decent debugger where in you can just execute the code step by step, explore the current variable values and check what exactly is happening. For example Eclipse or IntelliJ. If you don´t use an IDE, then just place some System.out.println() or Logger.debug() statements at strategic locations printing the variables of relevance so that you can track in logs what exactly is happening.
    or tell any other way to find is my page is thread safe or not...Just write correct code and narrow the scope of the variables as much as possible. If you for example assigned the user object to a static variable or as a servlet´s instance variable, then exactly the same user object would be used everywhere in the application. That kind of logical things.

  • How to handle screen resolution in bdc session method.

    hi all,
    how to handle screen resolution in bdc session method.

    Hello,
    Why do need that for? Is it to add rows on a table control??
    If it does, add new rows by using the add button instead of adding into the table control directly to each row.
    Bye
    Gabriel.

  • How to handle screen resolution in session method

    how to handle screen resolution in session method  without bdc_insert .

    Hello,
    Why do need that for? Is it to add rows on a table control??
    If it does, add new rows by using the add button instead of adding into the table control directly to each row.
    Bye
    Gabriel.

  • Newbie: How to handle a multi-step dialogue with no session?

    I can't see how to handle the following trivial problem:
    1. The user clicks on a button to retrieve values from the database
    2. The values returned are displayed in a table on the same page
    3. The user clicks a button next to the desired element
    4. Some action is performed
    I can achieve steps 1, 2, 3 but fail on step 4: the action is not called.
    One prerequisite is that I don't want to store anything in the session or application scope.
    In the example that follows, when you click on "Show Element" the action is not performed.
    This is myExample.jsp:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <HTML>
    <HEAD>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <TITLE>Test</TITLE>
    </HEAD>
    <f:view>
         <BODY>
         <h:form>
              <h:commandButton action="#{myExample.doSearch}" value="Search Database" />
              <p/>
              <h:dataTable value="#{myExample.elements}" var="elem" binding="#{myExample.dataTable}">
                   <h:column>
                        <h:outputText value="#{elem}"/>
                   </h:column>
                   <h:column>
                        <h:commandButton type="submit" value="Show Element"     action="#{myExample.doShowElement}"/>
                   </h:column>
              </h:dataTable>
         </h:form>
         </BODY>
    </f:view>
    </HTML>This is myExample.java:
    package example;
    import javax.faces.component.html.HtmlDataTable;
    public class MyExample {
         private HtmlDataTable dataTable;
         private String[] elements;
         public MyExample() {
         private String[] readFromDatabase() {
              return new String[] {"one", "two", "three"};
         public String[] getElements() {
              return elements;
         public void setElements(String[] elements) {
              this.elements = elements;
         public HtmlDataTable getDataTable() {
              return dataTable;
         public void setDataTable(HtmlDataTable dataTable) {
              this.dataTable = dataTable;
         public String doSearch() {
              elements = readFromDatabase();
              return "";
         public String doShowElement() {
              String selected = (String) dataTable.getRowData();
              System.out.println("Selected element: " + selected);
              return "";
    }This is in faces-config.xml
         <managed-bean>
              <managed-bean-name>myExample</managed-bean-name>
              <managed-bean-class>example.MyExample</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
         </managed-bean>

    Thank you for your answer.
    I didn't realise I could use inputHidden for anything more complex than a single string...
    I have added a h:inputHidden for the elements array but it still doesn't work.
    How should it be used?
         <h:form>
              <h:inputHidden value="#{myExample.elements}"/>
              <h:commandButton action="#{myExample.doSearch}" value="Search Database" />
    ...While debugging I noticed that at the last button-press the getElements method is called twice before setElements, returning null.

  • Can anyone tell me how the session expires once we logout the page?

    can anyone tell me how the session expires once we logout the page?
    After logout ,if we click back button, it wont goes to last page,please explain how to write a code in jsp?

    When we click logout the page redirects to logout.jsp or sevlet, there
    the code for removing the attributes and invalidating the session is written. and then redirect the page to other page
    Do You want some code???

  • How session Expire...!

    Hello Friends ,
    Can Anybody tell me how session expire apart from this code :
    session.invalidate();
    session.removeAttribute("Attributename");
    Is there any other reason of expiring session.

    Try using this in your deployment descriptor:
    <session-config> 
            <session-timeout>30</session-timeout> 
    </session-config>  ...where the number is given in minutes

  • How to forward automatically when session expires ?

    Hi Techies,
    whenever session expires , I want my struts action to forward to logout page automatically.
    I know we can do it by implementing sessionlistener(session destroyed method).
    But how to forward using action mapping .
    any solution is appreciated.
    Thanks,
    shekar

    HI,
    the other method for this is be prepared from the start
    of making of the project make an action class that
    extends
    org.apache.struts.action.Action
    class
    check all such type of thing ie the session and redirect to global forwards
    logout page
    and other required things
    always extend this ur own made action class
    so that it has all functionality of the struts action
    and ur own vlaidation too

  • In indianvisa App. page; when I clicking a link in this page after a long time (2 hours), it shows me session expired. how can i solve it? Please.

    http://indianvisa-bangladesh.nic.in/visa/indianVisaRegDetails.jsp; this is page link. I want to stay in this page for a long time but i can't, they show me a message "session expired". Also I set an add-on namely Session Keeper but don't implement it. Please solve my issue.
    Thanks
    Bishwajit Das

    Many site issues can be caused by corrupt cookies or cache.
    * Clear the Cache and
    * Remove Cookies<br> '''''Warning ! ! '' This will log you out of sites you're logged in to.'''
    Type '''about:preferences'''<Enter> in the address bar.
    * '''Cookies;''' Select '''Privacy.''' Under '''History,''' select Firefox will '''Use Custom Settings.''' Press the button on the right side called '''Show Cookies.''' Use the search bar to look for the site. Note; There may be more than one entry. Remove '''All''' of them.
    * '''Cache;''' Select '''Advanced > Network.''' Across from '''Cached Web Content,''' Press '''Clear Now.'''
    If there is still a problem,
    '''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]''' {web link}
    While you are in safe mode;
    Type '''about:preferences#advanced'''<Enter> in the address bar.
    Under '''Advanced,''' Select '''General.'''
    Look for and turn off '''Use Hardware Acceleration'''.
    Poke around safe web sites. Are there any problems?
    Then restart.

Maybe you are looking for

  • Changes to videos in album don't sync

    I had a video in iPhoto on my Mac that I duplicated, renamed, and then trimmed.  The original was in an album in iPhoto, and on my iPfhone in that same album. When I synced the iPhone, the trimmed video didn't show up, just the original.  So I took t

  • G-Drive Mini won't mount

    Hello all, A little back story: I used a 160gb G-Drive Mini with my 15 Al Powerbook G4 (w/OSX 10.4.11) extensively for a couple years with a firewire 400 cable. One day the drive's firewire port crapped out, and since the machine doesnt have the powe

  • Widescreen looks zoomed in on tv

    I've created a film in FCE 4. It wasn't filmed in widescreen, but changed to it in FCE on the timeline properties. I've exported>quicktime movie>not self-contained. Open the file in Quicktime Pro>window>show movie properties>video track, selected to

  • Retrive perticular mail using PL-SQL procedure

    Hi all, Anyone knows, how to retrive mails from outlook using PL-SQL procedure? Thanks and Regards Nilay

  • Choppy playback, freezing, slow re-indexing every time project opens

    Software: Premiere Pro CS5.5.2 Windows 7 Home Premium 64-bit Source footage AVCHD (MTS files) from a Panasonic TM300 (1920x1080). Hardware: Gigabyte Z77X-UD3H motherboard Intel i7-3770K CPU @ 3.50GHz 3.90 GHz Memory 16Gb NVidia GeForce GTX 680 (unloc