End of session operations

Hi
I have this problem with Tomcat 6.0:
I have a bean in session scope that is responsible for executing some MySQL operations (creating tables, inserting rows, deleting...etc). All these operations are temporary and the tables created by the this bean have to be deleted when the session is invalidated. I added these two methods to my bean:
public class ResultsBean implements Serializable, HttpSessionBindingListener
  /* Bind / Unbind operations */
  public void valueBound(HttpSessionBindingEvent event)
    //System.out.println("resultsBean was loaded!");
    this.sessionID = event.getSession().getId();
    init();
  public void valueUnbound(HttpSessionBindingEvent event)
    //System.out.println("resultsBean was unloaded!");
    finish();
}finish(), cleans up the tables the bean has created during the session.
The problem is that i would always have leftovers in MySQL from past sessions (not all but some). I know that the problem is somewhere with the invalidation process because looking into the logs I cannot see any attempts to cleanup the database for the sessions that left the mess.
My webapp web.xml is configured with 2 minutes timeout.
How can I initiate a proper cleanup process whenever a session is invalidated?
Is it possible to make a background process in Tomcat similar to Java's garbage collector?
Thanks!

That's what I was missing I didn't know the web.xml had a <listener> tag.
SessionCleaner.java:
package listeners;
import javax.servlet.http.*;
public class SessionCleaner implements HttpSessionListener
  /* Session Listener */
  public void sessionCreated(HttpSessionEvent sessionEvent)
    System.out.println("Session created: " + sessionEvent.getSession().getId());
  public void sessionDestroyed(HttpSessionEvent sessionEvent)
    System.out.println("Session ended: " + sessionEvent.getSession().getId());
}web.xml:
<!-- Listeners -->
<listener>
     <listener-class>listeners.SessionCleaner</listener-class>
</listener>
.Works like a charm.
stdout log:
Session created: 0E953FC8AEA6B5BE37F714D72F33DF1F
Session ended: 0E953FC8AEA6B5BE37F714D72F33DF1FThanks for the hint bandarurm!
Edited by: exkor5000 on Feb 27, 2009 5:20 PM

Similar Messages

  • How to end RDP sessions remotely from different network?

    Hi
    How to end RDP sessions remotely for windows 2008r2 server from different network?
    not from local LAN
    Thanks

    Hi
    what ports need to be open to successfully connect to server behind firewall?
    from WAN to LAN using :
    net use \\servername_or_IP /USER:username “password“
    or
    qwinsta /server:ServerIP
    Thanks

  • Prod order qty at the end of each operation

    Hi, my client want to monitor the qty of a production order at the end of each operation. can it be possible? say at the end of operation 10, the product A qty is 5, at the end of operation 20, the product B qty is 4 etc. pls advise what are all required to implement.

    Yadav,
    As suggested by the forum members you need to have operation confirmations i.e. CO11N.
    You can see the required report in COOIS or in the order itself against the every individual operations as confirmed quantity in operation overview.
    But as you required, it won't be inprocess material specific as you are not going to identify the inprocess stages as individual materials.
    Lets take as example, you have raw materials X,Y & SFG Z to have finished product A. The order contains 10 operations.
    We have issued X, Y & Z to the order on first operation. Now as per your client's requirement at the end of first operation that inprocess material will be identify with specific material code say P, at the end of second operation it would be Q & so on with quantity.
    But we don't define the inprocess material as particular material, you won't be having the same data.
    Even if you try it would be tedious job.
    So use standard report with the fields available. Or else go for customized report.
    Hope this helps you.
    SmanS

  • How to end user session correctly as sys or system user

    Hi,
    Database version Oracle 10.2.0.3
    We have to end user sessions to update database content. We cant stop/shutdown the instance but we have to assure that some users are not logged on.
    So we are looking for a solution to end some arbitrary user sessions as sys or system user without using the KILL USER SESSION option. We want to assure that the user sessions end correctly.
    Is there a possibility or a command in Oracle 10g to end a user session correctly ?
    Thanks for your assistance.

    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_2013.htm#i2053602
    I think DISCONNECT SESSION Clause is what you are looking for.
    Let us know if this is not the case.

  • Closing/ending a session in jsp

    Hi guys i need help ending my session. I am using session just for parameter passing, my webpages doesnt need login logout function.
    These are my basic code:
    page1.jsp
    <%
    String prodlinesel = request.getParameter("prod_line");
    session.setAttribute( "sessprodline", prodlinesel );
    %>
    page2.jsp
    <%= session.getAttribute("sessprodline") %>
    how,when &where do i end my session ? thanks so much

    You can use session.removeAttribute("sessprodline");
    Calling session.invalidate() will invalidate the session.
    Otherwise it disappears after it times out - normally after about 30 minutes of inactivity from that session.

  • How to create session and end the session in atg without using ootb

    can anyone send the code for creating session(Login) and ending(Logout) session in atg without using ootb.
    thankyou!

    It is plain simple and is plain old request.getSession(false) and then invalidate the session , but why do you want to do it separately . ATG works behind scenes to associate lot of attributes to the session when log in happens and then deassociates them when log out happens , SessionManager component is also helpful in security , can you state why exactly would you want to do it?

  • Forcing End Of Sessions

              Hi,
              I am attempting to implement Session management functionality that will allow
              Administrators to view and if necessary end a User's or a given set of Users HTTP
              Sessions forcing them to re-logon. I am considering using HttpSession.invalidate()
              to end the sessions. This is fine so long as the user is not in the middle of
              a request but if in the middle of a request I am concerned that it will cause
              some nasty errors.
              Is there a better way of safely ending sessions and if a session is invalidated
              mid request will this end the request?
              Thanks in advance for any info or suggestions.
              Jim
              

              Hi,
              Thanks for that. I originally thought that invalidating the sessions was the neatest
              solution but based on the fact that it will kill any requests in midstream (probably
              not ideal for what I am doing) I think I will just update the User's session to
              indicate that they should re-logon. If the User executes another request they
              will be automatcially re-directed to logoff/re-logon.
              Thanks again for your help.
              Jim
              "KP" <[email protected]> wrote:
              >
              >Hi Jim
              >Your concern about "in the middle of a request" is correct and chances
              >of IllegalStateException
              >generation is high. But if think, you must do it, catch this exception
              >and redirect
              >user to login page.
              >Cheers
              >KP
              >
              >"Jim Donnelly" <[email protected]> wrote:
              >>
              >>Hi,
              >>
              >>I am attempting to implement Session management functionality that will
              >>allow
              >>Administrators to view and if necessary end a User's or a given set
              >of
              >>Users HTTP
              >>Sessions forcing them to re-logon. I am considering using HttpSession.invalidate()
              >>to end the sessions. This is fine so long as the user is not in the
              >middle
              >>of
              >>a request but if in the middle of a request I am concerned that it will
              >>cause
              >>some nasty errors.
              >>
              >>Is there a better way of safely ending sessions and if a session is
              >invalidated
              >>mid request will this end the request?
              >>
              >>Thanks in advance for any info or suggestions.
              >>
              >>Jim
              >
              

  • How can i check that who end the session

    Hi to all ,
    my query is that how can i check that who end the session.
    through SM04 user who have the authontication can end the session so how can i check that who end the session being a BASIS admin.
    Thanks & Regards

    It's wrotes in system log, check in sm21.
    Regards.

  • My Assets iView problem (ESS 50.1.) - "End of Session" returns from ITS

    Hi guys!
    I have problem with some IAC iViews of ESS 50.1. BP. When I click the link to some of them - My Assets for example, I get screen from its with following message:
    End of Session. Thank you for working with Internet Transaction Server.
    Other iViews from the BP work fine.
    What could be the problem?
    Thanx for answers!
    Olian

    Hi guys!
    I have problem with some IAC iViews of ESS 50.1. BP. When I click the link to some of them - My Assets for example, I get screen from its with following message:
    End of Session. Thank you for working with Internet Transaction Server.
    Other iViews from the BP work fine.
    What could be the problem?
    Thanx for answers!
    Olian

  • Leave request ITS end of session error

    Hi,
    There are few users who are a getting a error saying "End Of Session Thank you for working with the Internet Transaction Server! " when they tried to access leave request ( ws20000081) and leave request overview ( ws01000109). this error is coming to particular cost center users, all other users doesn't have this problem. furthermore we have given the auth as well.
    For these particular users they have been performing ESS tasks before and this issue came 3weeks back.
    i checked the HR org structure nothing has been changed. please help
    Regards
    Aflal

    can you check the same service being launched from r/3 ie
    enter /n
    and then ws20000081
    execute.
    This is the case most likely with ITS templates
    See the following SDN and HELP.SAP.COM site which will provide more
    information.
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/home/
    InternetTransactionServer&
    How to terminate a user session with integrated ITS when the transaction
    ends?
    and note
    959417, "Integrated ITS, Closing Session When Transaction Ends"
    Re the "redirection" please review the following:
    SAP Note 916727.

  • Ending a Session

    Does anyone know of a way to end a session (AKA force a user to logout) is the same user name is used to logon somewhere else? I have an application where if a username is used to login twice to the same application AKA the user has two open sessions the previously open session needs to be deleted.
    When a user logs on it records there sessionid and user id to a table in the database, so I have the session id of the session i want to kill.
    Thank you in advance for any help. Let me know if that still sounds to confusing.

    Yes, the code I showed in the other post.
    sessionKill.cfm
    <cfset structClear(session)>
    <!--- This will clear the current session of all data, which should log out any user since the login state is ususlly stored in the session scope --->
    Some file somewhere the detects a user has been logged in twice
    <cfhttp url="sessionKill.cfm?cfid=#otherSessionCFID#&cftoken=#otherSessionCFTOKEN#"...>
    <!--- This will make an HTTP request passing in the known id and token of a session, that session should then have all it's data cleared by the sessionClear() function--->
    As I said, this does not actually remove the session from memory of ColdFusion.  That can't be done without mucking around with the serviceFactory.  But the session will have no data and if a user where to return to it they should not be logged in or have any saved data.

  • End Dating an operating unit.

    We have stopped transactions in one of the Operating Unit, now we want to set an end date this Operating unit, so that the user cannot enter further transactions,however they shall be allowed to check the historical data.
    We are on Oracle 12.0.6
    Regards,
    Deepak Kothari

    Hi..
    You can end date the organization very simply..
    Navigation:
    Work Structures -> Organization -> Description
    Query the exact Organization.
    You could see the End Date Field in the form and give the appropriate Date..
    Note: You could not end date organization if any employee's have any future assignments on tat org..
    Regards
    Guru

  • End of Session ITS

    Hi!
    I have problem with transaction iView in ITS, When I click the execute botton, I get "End of Session - Thank you for working with Internet Transaction Server" text. What's wrong? Why is not displayed the transaction? Other transactions incl. Leave Request are O.K. Can it be problem with publishing?
    Thanks.

    Hi!
    I have problem with transaction iView in ITS, When I click the execute botton, I get "End of Session - Thank you for working with Internet Transaction Server" text. What's wrong? Why is not displayed the transaction? Other transactions incl. Leave Request are O.K. Can it be problem with publishing?
    Thanks.

  • Since updating to IOS 6, my autolock is not work if I end the session in Messages, Notes Or Calendar. What's up

    since updating to IOS 6, my autolock only works tf I end the session in phone. What's up?

    I have the same problem too.

  • Handling End of Sessions

    Hello,
              I want to handle end of a session. I want to redirect the user to the Login
              page when the session ends.
              What is the best way to do it? Is there an event that is generated when the
              session ends? If so how will my Servlet get that Event?
              I am using a combination of Html, Servlets, and JSP (transparently compiled
              to Servlets).
              Thanks in advance
              

              [email protected] wrote:
              > Thanks for the information. I understand how I can invalidate a
              > session.
              OK.
              > What I was looking for is a little different. How can I
              > FIND WHEN THE WEB LOGIC SERVER ENDS MY APPLICATION SESSION?
              > Do my application get an event so that I can invalidate the session
              > and send the user to the logon page?
              You cannot find when the WLS ends your session unless & until you write
              your own version of Event class.
              HttpSessionBindingListener is a best bet to implement this feature.
              (Causes an object to be notified when it is bound to or unbound from a
              session. The object is
              notified by an HttpSessionBindingEvent object)
              1. Create a class say NotifySessionTimeout that implements
              javax.servlet.http.HttpSessionBindingListener
              2. create an object of the above class and attach it to user session
              3. when the session is removed NotifySessionTimeout.valueUnbound( ) will
              be called by the servlet engine.
              4. you can implement valueUnbound( ) to do whatever you want.
              Kumar
              >
              >
              >
              >
              >
              >
              > Allamraju Kumarswamy wrote:
              >
              >> Sailaja--
              >>
              >> You can invalidate the current session by calling
              >> session.invalidate( ) .
              >> Where session is HttpSession's object.
              >>
              >> For this you might want to configure the session tracking in
              >> weblogic.properties file
              >>
              >> weblogic.httpd.session.enable=true (already set to true)
              >> weblogic.httpd.session.timeoutSecs=x
              >>
              >> Sets how long WebLogic waits before timing out a session, where x is
              >> the number of seconds between
              >> a session's activity.
              >>
              >>
              >> Hope this helps.
              >>
              >> Kumar
              >>
              >> Sailaja wrote:
              >>
              >> > Hello,
              >> >
              >> > I want to handle end of a session. I want to redirect the user to
              >> > the Login
              >> > page when the session ends.
              >> >
              >> > What is the best way to do it? Is there an event that is generated
              >> > when the
              >> > session ends? If so how will my Servlet get that Event?
              >> >
              >> > I am using a combination of Html, Servlets, and JSP (transparently
              >> > compiled
              >> > to Servlets).
              >> >
              >> > Thanks in advance
              >>
              [att1.html]
              

Maybe you are looking for

  • Add a new hard-drive

    Hi, I need to install a new hard-drive in order to upgrade to Solaris 10. Solaris 8 is currently installed. If I do a probe-all while booting, I can see both hard-drives and the cdrom drive. But when I want to format the disk, it is not recognised (f

  • Import material consumption

    Dear All, i have created material same material i used local procurement & import procurement. my clients requirement is that separate consumption for local as well as import is it possible bcz mat type is RM. please guide me & in future how to work

  • Load balancing for BPEL Cluster

    Can anybody tell how to configure the load balancer in BPEL Cluster ..? I am not able to get the correct documents for that. I want the request from the client can be redirect to any of the cluster server that will be having the PPEL Process deployed

  • Creation of hierarchy structure

    Hi all, I need help bulding a hierarchy structure which is time dependent (hierarchy structure time dependent). I want to know if the hierarchy structure only depends on the NodeID and ParentID or if the time information is (date from and date to) is

  • If you drop a MV log then do you have to recreate the MV?

    If you drop a MV log then do you have to recreate the MV in order for the MV to work again. i.e. -- I create MV log and MV (10 second refresh) on 2 different DB machines -- I drop the MV Log -- MV will not get refreshed -- I recreate the MV log Now w