Re: get list of open session

Hello, if i get sessions like
public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
            throws ServletException {
            request.getSession().removeAttribute("web_user");
  }is there is a way to find, list of open sessions, or list of ppl who loged into the system?

A session is associated to a user. Removing an attribute from a session will have no impact on other sessions. You will have to store the currently active users in a higher scope (one thats common to all users - ServletContext is a good choice).
You will also have to use a combination of listeners to achieve this.
Assume you have a user object bound to each session (that stores the logged in user info).
some login process inside, say a Servlet
User userObj = new User();
//userObj.setXXX() setter methods that store user data in this object
request.getSession.setAttribute("web_user", userObj);Step 1.
Create a list to hold all active users in your context object. This list is instantiated when the context fires.
public class CtxListener implements ServletContextListener{
     public void contextInitialized(ServletContextEvent ctxEvent){
          ctxEvent.getServletContext().setAttribute("currentUsers", new ArrayList());
     public void contextDestroyed(ServletContextEvent sce){}     
}Step 2
Use a HttpSessionBindingListener that informs you when a UserObject is bound to a session.
public class User implements HttpSessionBindingListener {
     //variables and get/set methods go here
     public void valueBound(HttpSessionBindingEvent event){
          //get a handle to the context page
          ServletContext ctx = event.getSession().getServletContext();
          //get a handle to the user's list ctxt attribute
          List userList = (List)ctx.getAttribute("currentUsers");
          //add this object to the user list
          userList.add(this);
     public void valueUnbound(HttpSessionBindingEvent event){
             //do nothing
            //we will remove logged out users in a different manner
}Step 3
Now at any point where you have access to the ServletContext(which is virtually everywhere in a web application), you can get the list of users in the following fashion.
//some servlet
     List currentUsers = (List)getServletContext.getAttribute("currentUsers")
}Step 4
We have to remove logged out users. Do it using a SessionListener
public class SessionListener implements HttpSessionListener{
     public void sessionCreated(HttpSessionEvent se){
     public void sessionDestroyed(HttpSessionEvent se){
          HttpSession session = event.getSession();
          ServletContext ctx = session.getServletContext();
          List currentUsers = (List)ctx.getAttribute("currentUsers");
          currentUsers.remove(session.getAttribute("web_user"));
}You should ofcourse register your listeners in web.xml
Cheers,
Ram.

Similar Messages

  • Getting list of open files

    I have two related questions. How can I get a list of all the files that are currently open on a particular machine? I'm using Windows, so I don't know of anything like Runtime.exec("lsof");. More specifically, I need to see if a particular (given) file is currently open.
    The second question that I have is how can I see if a particular file is open via a (signed) applet, with whatever security manager the browser has installed?
    Thanks a lot.
    --Jay                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    There is no way to do this in pure java.
    Given that, why do you feel you need to do this?I have an applet that takes a group of files,
    compresses them together, and then uploads and
    downloads the compressed archive to/from a server and
    uncompresses them on the download end. Of course, if
    one the files that's supposed to be archived or
    unarchived is open, the applet won't work. I'm trying
    to write some code that, if one of these files is
    open, will notify the users that they have to close
    them.Just attempt the operation of archiving/unarchiving, and deal gracefully with the possible exception, such as notifying the user of the failure at that point.
    Even if you could determine if all the files weren't open, as soon as you determine that, the determination can be stale anyway as one or more of those files could subsequently be opened while you're trying to do the archive/unarchive operation, and you'd still have to deal with it.

  • When I open a PDF, I want to choose from 3 applications, not just 2 plus other. How can I change the number of recent applications that get listed for opening a file type?

    I'd like firefox to remember the 3 most recently used applications per file type, not just the most recent 2.

    On my Windows 7, with any browser, all downloaded files go into the Downloads folder.
    If you can't find your downloaded PDF docs, try a search for *.pdf

  • What is the proper way to close all open sessions of a NI PXI-4110 for a given Device alias?

    I've found that, when programming the NI PXI-4110 that, if a the VI "niDCPower Initialize With Channels VI" (NI-DCPower pallette) is called with a device
    alias that all ready has one or more sessions open (due to an abort or other programming error) a device reference results from the reference out that has a (*) where "*" is post-fixed to the device reference where and is an integer starting that increments with each initialize call. In my clean up, I would like to close all open sessions. For example, let's said the device alias is "NIPower_1" in NI Max, and there are 5 open sessions; NIPower_1, NIPower_1 (1), NIPower_1 (2), NIPower_1 (3), and NIPower_1 (4). A simple initialize or reset (using niDCPower Initialize With Channels VI, or, niDCPower Initialize With Channels VI, etc.) What is the proper way to close all open sessions?
    Thanks in advance. Been struggleing with this for days!

    When you Initialize a session to a device that already has a session open, NI-DCPower closes the previous session and returns a new one. You can verify this very easily: try to use the first session after the second session was opened.
    Unfortunately, there is a small leak and that is what you encountered: the previous session remains registered with LabVIEW, since we unregister inside the Close VI and this was never called. So the name of the session still shows in the control like you noted: NIPower_1, NIPower_1 (1), NIPower_1 (2), NIPower_1 (3), and NIPower_1 (4), etc.
    There may be a way to iterate over the registered sessions, but I couldn't find it. However, you can unregister them by calling "IVI Delete Session". Look for it inside "niDCPower Close.vi". If you don't have the list of open sessions, but you have the device name, then you can just append (1), (2) and so forth and call "IVI Delete Session" in a loop. There's no problem calling it on sessions that were never added.
    However - I consider all this a hack. What you should do is write code that does not leak sessions. Anything you open, you should close. If you find yourself in a situation where there are a lot of leaked sessions during development, relaunching LabVIEW will clear it out. If relaunching LabVIEW is too much of an annoyance, then write a VI that does what I described above and run it when needed. You can even make it "smarter" by getting the names of all the NI-DCPower devices in your system using the System Configuration or niModInst APIs.
    Hope this helps.
    Marcos Kirsch
    Principal Software Engineer
    Core Modular Instruments Software
    National Instruments

  • List of open orders

    Hi Guys,
    How to get list of open orders in table??

    try out VA05.
    if it is sales office level information, is required then you can have the sales office column added using the available layout options in VA05.
    if the sales man is marked under partner function, then you may need to extract the VA05 output & filter the sales order using VBPA table with parameters of sales man controlled in the selection screen.
    rgds
    ilango

  • My back button and refresh button and my yahoo tool bar are dimmed a lot when I open up firefox. So as a result, I cannot use the back button nor my refresh button AND my yahoo toolbar disappears a lot. I have tried to get on your chat session but it is a

    <blockquote>Locked by Moderator as a duplicate/re-post.
    Please continue the discussion in this thread: [/forum/1/688252]
    Thanks - c</blockquote>
    == Issue
    ==
    I have another kind of problem with Firefox
    == Description
    ==
    My back button and refresh button and my yahoo tool bar are dimmed a lot when I open up firefox. So as a result, I cannot use the back button nor my refresh button AND my yahoo toolbar disappears a lot. I have tried to get on your chat session but it is always closed. I need one on one help. Please reply with resolution.
    == This happened
    ==
    Every time Firefox opened
    == two or three months ago
    ==
    == Firefox version
    ==
    3.6.3
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 (BT-canvas) Firefox/3.6.3 GTB7.0 (.NET CLR 3.5.30729)
    == Plugins installed
    ==
    *-npdnu
    *npdnupdater2
    *Coupons, Inc. Coupon Printer DLL
    *Coupons, Inc. Coupon Printer Plugin
    *The QuickTime Plugin allows you to view a wide variety of multimedia content in Web pages. For more information, visit the QuickTime Web site.
    *6.0.12.448
    *RealPlayer(tm) LiveConnect-Enabled Plug-In
    *RealJukebox Netscape Plugin
    *Default Plug-in
    *Adobe PDF Plug-In For Firefox and Netscape "9.3.2"
    *BrowserPlus -- Improve your browser! -- http://browserplus.yahoo.com/
    *Shockwave Flash 10.0 r45
    *Yahoo Application State Plugin version 1.0.0.7
    *3.0.50106.0
    *My Web Search Plugin Stub for 32-bit Windows
    *Google Updater pluginhttp://pack.google.com/
    *Google Update
    *Next Generation Java Plug-in 1.6.0_20 for Mozilla browsers
    *Npdsplay dll

    * If the menu bar is hidden then press and hold the Alt key down, that should make the Menu bar appear (Firefox 3.6 on Windows) (see [[Menu bar is missing]]).
    * Make sure that you have the ''Navigation Toolbar'' and other toolbars visible: View > Toolbars .
    * If items are missing then see if you can find them in the View > Toolbars > Customize window.
    * If you see the item in the Customize window then drag it back from the Customize window to the Navigation toolbar.
    * If you do not see that item then click the Restore Default Set button in the View > Toolbars > Customize window.
    See also [[Back and forward or other toolbar buttons are missing]] and [[Navigation Toolbar items]]
    See http://kb.mozillazine.org/Toolbar_customization

  • How can I get a list of open web pages in Firefox (in Linux)?

    I would like to know how to get a list of open web pages in Firefox (in Linux), because I have a shortcut to open a web page and I want to get it to see if Firefox has the page open first so that it doesn't open duplicates.

    You see the "List All Tabs" button in current Firefox versions if there are that many tabs open that you get the Tab bar scroll buttons appearing.
    Add code to the userChrome.css file below the default @namespace line.
    *http://kb.mozillazine.org/userChrome.css
    The customization files userChrome.css (user interface) and userContent.css (websites) are located in the chrome folder in the Firefox profile folder.
    *http://kb.mozillazine.org/Editing_configuration
    <pre><nowiki>@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    #tabbrowser-tabs ~ #alltabs-button { visibility:visible!important; }
    </nowiki></pre>
    * Permanent List-all-tabs Button: https://addons.mozilla.org/firefox/addon/permanent-listalltabs/

  • I am having a problem when I try to select a photo or itunes song in Imovie or other programs. I get a window with grey lettering that says: "Open Itunes to populate this list" or "Open iphoto to see photos from your iPhoto library in this list.  I have t

    I am having a problem when I try to select a photo or itunes song in Imovie or other programs. I get a window with grey lettering that says: "Open Itunes to populate this list" or "Open iphoto to see photos from your iPhoto library in this list.  I have tried relaunching programs and nothing appears. Seemed to start happening a while back after one of my system upgrades.

    After a a lengthy conversation with Apple Tech. ($20), my problem seems to be solves. The Iphoto problem solved by trashing the plist file. The Itunes was more involved. We had to create a new Itunes folder and import the files into the new folder; and then import the playlists.

  • Getting error code -251723766 returned from the "EthernetIP Open Session.vi" while trying to talk to a PLC

    I have created a LabVIEW application using LabVIEW 2012 (64 bit) that attempts to communicate with a PLC. I do not actually have the PLC here at the Rockwell Collins facility in Cedar Rapids, Iowa.
    I have sent this application to my co-worker, who is located at a different Rockwell Collins facility in Tustin, California, where the PLC is actually located.
    My coworker in California is reporting that when he starts up my application under WIN7 he gets an error code of "-251723766" when the S/W performs the "Open Session" function during initialization.
    I looked at the online help and the value "-251723766" is not defined.
    When I run the same application under WIN7 here in Cedar Rapids I do NOT get the runtime error code of "-251723766" during initialization.
    Do you have any ideas for what is causing this problem?

    Hello
      I never really understood what the session parameter was all about.
      The documentation says that the session parameter is optional.
      Based on your advice I have deleted the code from my block diagram that was doing an Open Session.
      Are there any example LabVIEW programs that I can study that actully use the Ethernet/IP S/W to connect to a PLC?
      I have attached 2 screen captures that show how my LabVIEW VI's are accepting the session parameter.
      Do you think I should delete the input and output parameters for session?
      Please let me know.
      Thank you
      Todd J. Miller
      319-295-8689
    Attachments:
    OpenSessionProblem#4.jpg ‏107 KB
    OpenSessionProblem#5.jpg ‏189 KB

  • To get the list of all session-id-owner

    Hello from Vienna,
    It is about a website, the user, who is already logged in, has a session-id.
    a) How can i get all the list of the users, who currently have a session-id ?
    b) How can i list the current session-ids (which still are active)
    That ist a question of an exam.
    many thanks

    You can store every session id (or token) in a data base. When user logs in You simply assign the user with token and save this token into data base, the token of course has a "valid thru" field. Then when You need to list the users You make a query that gets the users with tokens that are still valid.
    I don't know if this can be done plainly on the servlet side.

  • I want to get List of all active sessions in current system

    Hi experts
    How to get list of all active sessions in current system in any internal table along with details.
    A sample code wud be helpful
    Thanks in advance.

    try this code it might help u.
    Below report execution gets the active Session list to ABAP memory
    submit rsm04000_alv and return exporting list to memory.
    refresh: gt_listobj.
    Below FM get the List output from ABAP memory to gt_listobj in HEX
    call function 'LIST_FROM_MEMORY'
      tables
        listobject = gt_listobj
      exceptions
        not_found  = 1
        others     = 2.
    if sy-subrc <> 0. " Executed successfully ?
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    This FM converts ITAB gt_listobj from HEX to ASCII
    call function 'LIST_TO_ASCI'
      tables
        listasci           = it_list
        listobject         = gt_listobj
      exceptions
        empty_list         = 1
        list_index_invalid = 2
        others             = 3.
    if sy-subrc <> 0. " Executed successfully ?
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    This Shows the output in List format on screen
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
       i_structure_name                  = 'line'
      tables
        t_outtab                          = it_list
    exceptions
       program_error                     = 1
       others                            = 2.
    if sy-subrc <> 0. " Executed successfully ?
    message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.

  • Is it possible to get a list of open Actionscript documents in Flash CC?

    I am looking at the javascript API of Flash CC. I can register an event listener for documentNew, documentOpened, documentClosed, etc, and I can get a list of open documents. Those seem to be only for .fla documents, not for .as. Is it possible to get the .as files somehow? I guess I could try to search for the classes in the classpath myself, but I want to limit this to only the documents that are edited at the moment. Is there any API for the text editor?

    DaveRines wrote:
    I specifically want to be able to programmtically save and close an open excel workbook that has not yet been saved and I don't know the name of. From Labview.
    I know how to manipulate workbooks that I open from a saved location, but don't know how to take whichever workbook is open on my computer and save it to a known location.
    Thanks!
    I saw this post and thought there might be a similar method for ActiveX objects that there is for vi's:
    http://forums.ni.com/t5/LabVIEW/Is-it-possible-to-get-a-list-of-refnums-to-all-VIs-loaded-into/td-p/...
    This should work:
    If you want to change the path or have more control on the options, you could replace the '_Workbook/Save' method with
    In this case, if you want to avoid additional pop-ups, make the 'Visible' and 'DisplayAlerts' properties FALSE when you open the Application in the first ActiveX node

  • How to get list of company codes with current period not opened?

    Hi,
    How to get list of company codes with current period not opened?
    Is there any way we can check whether the current period is opened for all company codes.
    If not how, can we generate a report which having information of period and company code. Also please tell me, which table will have info on posting periods and company codes.
    Thanks
    Vineeth Varghese

    Hi,
    The MM periods details can be viewed In Table MARV . On the selection screen you have the option of entering the company codes , current period, year current period etc. so make the required entries and you get the all details relevant to MM periods. Also it can be downloaded as a report.Thanks

  • The list of open web pages just flipped from right to left. How do I get it back on the right? Thankyou.

    The list of open web pages, which normally sits bottom right on my screen, flipped to the left. How can I move it back to the right?
    I clicked Alt + tab and saw 'Deplacer' (Reposition - I'm in France). Then the cursor became a thing like a crossroads and I clicked where I wanted to put the list of open pages but nothing happened.

    You may have placed the bookmarks icon on the Navigation Toolbar to open the bookmarks in the sidebar instead of the bookmarks menu button that opens a drop down list.<br />
    There are two icons available for opening or accessing the bookmarks that both have a star.<br />
    The icon with the drop marker opens the drop down list with the bookmarks (Bookmarks Menu button).<br />
    The other, without the star, opens the bookmarks in the sidebar, just like the Ctrl+B shortcut or View > Sidebar > Bookmarks
    See:
    *https://support.mozilla.org/kb/Back+and+forward+or+other+toolbar+items+are+missing
    *http://kb.mozillazine.org/Toolbar_customization

  • Open session problem.

    I am using 11.1.2.1 Jdeveloper and i have problem with open sessions.
    I set in appModule pool, min available size: 0
    I set in Db Conexion pool, min available size:0
    This are the step i am doing to get the problem:
    - I Clic on search button from inputListofValue, until request end i turn off pc wifi.
    - I wait 1 minuts and then I turn on pc wifi again.
    - Open another window from Internet Explorer and enter to the same web page.
    After that i check session and i find two open session:
    1 - first session is executing a query ( is the query from list of value)
    2 - second session is inactive (session actually i have)
    I take a picture in this moment:
    http://s2.subirimagenes.com/imagen/previo/thump_7690052open-connections.png
    after wait idle timeout from appModule pool the second session die but first session is open.
    First session is executing query for eternity!! I hear that ADF kill transaction when transaction time is long but maybe dont work bc i check next day and first session is open.
    I dont want to check disconnect db conexion option from appmodule configuration bc that force to kill sessions after each request and that lose temporal table data.
    Any help plz??

    Hi
    I find there is jbo.ejb.txntimeount in appmodule properties
    descriotion says:
    time after the application module session bean transaction expires
    by default is 1830 = 30 minuts.
    but transaction is never killed... so maybe a bug?? bad configuration??, hlp please

Maybe you are looking for

  • What versions should I DOWNgrade to?

    So I see that Apple decided, with the new version of OS X and iTunes that I installed, that note files can't be simply copied to the iPod anymore, the way they used to. Instead, you have to have an internet connection on your Mac and go through the M

  • Forms 11g  and FRM-40010

    Hi, i have installed Forms 11g (11.1.1.3) on a local machine , when i try to run a form on teh local disk it work properly, but when i copy the fmb on a network folder ( called T:) it give to me the error FRM-40010 . any idea ??? Gimbo

  • EPM 11.1.1: Cyrillic aliases issue in planning

    Hi all, I'm using EPM 11.1.1 and trying to load dimensions via csv file to planning application. But when I load cyrillic alisases I don't see them in application. When I replace cyrillic alises with latin everything is ok. So the problem is in cyril

  • Changing File Names in "Get Info"

    Every time I add a few songs to iTunes i shows up as track "and then the number" is there any way in finder to change this permanently? I know that it is blocked under "get info" and then "more info" tab. I know that you can change this in itunes but

  • My iTunes will not install the latest 12.0 update

    Okay, I'll start from the beginning. I wanted to put a load of my own songs onto my iPhone 4s, but it came up with the box "iPhone won't work unless latest update is performed" or something of the sort. So as you do I went to download the latest upda