Monitor Swing events in JSP

How can I monitor a Swing object's events in a jsp page. Namely, my jsp has an <object> tag which defines a cache_archive param for a jar file. This jar file has a class that creates Swing jbuttons, jpanel and jprogressbar. How can my jsp keep track of these jbuttons and their events?
Thank you,
Igor
Message was edited by:
eazyigz

1) When the JSP runs, it simply generates HTML, at which point the JSP page's job is done.
2) The HTML gets read by the browser and displayed.
3) The browser sees the object/embed tag and loads the jar file and then runs the applet.
At this point, the applet can certainly connect back to the server. Depending on what you need to do, it may differ. Generally, you will fall into 1 of 2 categories:
1) You just need to move to a new page: In this case, you just call applet.getAppletContext().showDocument() with a URL. That can target a frame or a window, or just replace the contents of the current page (closing the applet). The URL you use can have parameters attached in the standard HTTP GET URL format.
2) You need the applet to load some data: In this case, you use URLConnection to send a request to the server. This can be GET or POST. There's plenty of examples around the forums for either. This will not close the applet, the browser won't see the response, you have to handle everything within the applet itself.
Message was edited by:
bsampieri

Similar Messages

  • Package javax.swing.event not found in import.

    I'm receiving the above error message when compiling a Java application which begins with the following import statements:
    * 1.1+Swing version.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    My Classpath System variables are as follows:
    C:\IBMCON~1\CICS\Classes\CTGCLI~1.JAR;.;C:\PROGRA~1\MQSeries\java\lib\COMIBM~2.JAR;C:\PROGRA~1\MQSeries\java\lib\COMIBM~1.JAR;C:\PROGRA~1\MQSeries\java\lib\COMIBM~3.JAR;C:\PROGRA~1\MQSeries\tools\javaclnt\samples\en_us;C:\Program Files\SQLLIB\java\db2java.zip;C:\Program Files\SQLLIB\java\runtime.zip;C:\Program Files\SQLLIB\bin;C:\Program Files\SQLLIB\java\SQLj.zip
    I have Java(TM) 2 SDK, Standard Edition, Version 1.4.0 installed and am running Windows 2000.
    I'd appreciate any ideas as to why this compiler error occurs. Thanks very much.

    What error message?
    As stated, looks like something's not where it's supposed to be.
    Here's the search order of your classpath:
    C:\IBMCON~1\CICS\Classes\CTGCLI~1.JAR
    C:\PROGRA~1\MQSeries\java\lib\COMIBM~2.JAR
    C:\PROGRA~1\MQSeries\java\lib\COMIBM~1.JAR
    C:\PROGRA~1\MQSeries\java\lib\COMIBM~3.JAR
    C:\PROGRA~1\MQSeries\tools\javaclnt\samples\en_us
    C:\Program Files\SQLLIB\java\db2java.zip
    C:\Program Files\SQLLIB\java\runtime.zip
    C:\Program Files\SQLLIB\bin
    C:\Program Files\SQLLIB\java\SQLj.zip

  • Swing event queue, modal dialogs, event threads, etc...

    Hey all,
    So I am playing around with the focus manager, swing event thread and event queue, etc. Learned quite a bit. I am also playing around with test automation of our UI, using jfcUnit. I have written a few simple apps to play aorund with record/playback, coding tests, etc. What this thread is about though, is figuring out how modal and non-modal dialogs "take over" the event thread/queue? The reason I ask is, if I put a simple test harness like tool embeded in my app as a separate pop-up modal dialog, and from within it there is a GUI that I can use to select a "Test" to run. Now, when I run this test, jfcUnit needs to run on the main window, not within my non-modal dialog. What I am not sure of, however, is that if by using a non-modal dialog all events will go to the main event thread? I mean, I know if I mouse over my second non-modal frame (spawned from the application frame), that events will trigger for that dialog. I remember reading somewhere that modal dialogs "block" the main event queue, all left over events are given to the newly added event queue (presumably by the modal dialog) and existing left-over events get moved to the event queue. If that is the case, I am curious why events for the "old" queue are moved to the new queue if they were orginally intended for the old queue? I would think a "flush" before adding a new queue would be more appropriate so that the old queue can process all of its intended events.
    Now, I am just about to try this, but I am hoping a non-modal pop-up will not interfere with the jfcUnit running the UI of the main window. I am guessing, however, that it might. How are non-modal dialogs handled in terms of events and the event queue? Is it the same as modal dialogs? Or is there no blockage of the mainwindow event queue? If there is no blockage, than any sort of automation based on relative positions to a window may occur on the non-modal dialog, in which case it's best to hide the non-modal dialog during running of these tests.
    What are your thoughts, or better yet, knowledge of this topic? A decent explanation from a developer standpoint and not from the API's which dont give some of the more detailed info I am seeking is what I am hoping to get out of this.
    Thanks.

    Check this out. First, AWTListener has a LOT of
    different types you can register it for. I ORd all
    them together and when I ran my app, it took almost 30
    minutes for it to show up because of the huge stream
    of events being spit out via System.out. ...Yes, that doesn't surprise me in the least. There's hundreds of events that are fired around, usually unbeknownst to the user for every little thing. Lots of component and container events, in particular.
    Just make sure you OR ( using | not || ) ALL the
    "mask" values you want to watch for. That may be why
    you aren't seeing anything. When I did all that, and
    opened a menu, a ton of events came out.Maybe, I'll try that again, but I did specifically add an ActionEvent mask to get action events, and that should be all I need to get action events on buttons or menu items, and it wasn't getting them for either. It was only getting events on buttons when I used SwingEventMonitor, but not menu items.
    So I don't quite understand enough of the underlying event handling. Although, I suspect it could have something to do with the fact that these are Swing components, not AWT components (which their native peers) and it's pretty clear from AbstractButton (or was it DefaultButtonModel) how ActionEvents are fired, and they don't seem to have any connection to the code that deals with AWTListeners.
    My problem is that I kinda need a way to catch events without having a listener attached directly. Normally, I would have a listener, but there's this situation whereby an action may be triggered before I can get hold of the component to attach my listener to it. Perhaps I can get mouse press/release and just deal with it that way.
    Let me know if you did that and still didn't see what
    you were looking for. After playing with this, I am
    guessing the main reason for AWTListener is to
    register a listener for a specific type of event,
    instead of listening to them all, hence avoiding lots
    of extra overhead. Then again, the main event
    dispatcher must do a decent amount of work to fire off
    events to listeners of specific awt event types.Yes, it's definitely that. There's no point in sending events if no one is listening for it, so it does save some time.
    You are right, popup menus I think are dialogs, I
    don't know for sure, but you can access them via the
    JMenu.getPopupMenu() and JMenu.isPopupShowin().
    However, I am still not getting my test stuff working
    quite right.
    Yes, for menu popups. For a JPopupMenu on a right-click on any component (tree or whatever), I had a need to know about that from any arbitrary application (it's this GU testing app I'm working on), and since the popup menu doesn't belong to any component before it's shown, I couldn't necessarily know about it til it was displayed. I managed to use a combination of HierarchyEvents (using an AWTEventListener) and "component added" ContainerEvents. Not a simple matter, but it seems to work well.

  • Handling mouse events in JSP

    Hi ,
    I have to handle mouse events in JSP,means i have to handle the event
    of the user i.e, if he press the lest click we have to handle that
    event where he pressed it with JSP. Iam finding examples in Applets ,
    nut i have to do it in JSP.Can any body help me please? it's very
    urgent.
    Thanks in advance
    BhargavKumar.B

    JSP cannot catch mouse events. You need a clientside language for that, such as Javascript. So catch the mouse click event in Javascript, get the desired information from it and send it as request parameters to the server, so that the serverside logic can intercept on it. You can use AJAX for that, if you want to do it asynchronously.

  • Using swing elements in JSP pages

    I am developing a web application using jsp pages. In this application i want to display some information in a seperate window. For this i created a class which extends JFrame. This class makes also use of the singleton principle.
    In the jsp i use the following code (singleton class is called Statistics.class:
    <%
    /** statswindow try
    JFrame eTAFframe = Statistics.getInstance();
    eTAFframe.pack();
    eTAFframe.setLocation(485, 420);
    eTAFframe.setVisible(true);
    /*end statswindow try */
    %>
    After deployting the application on an Iplanet Application Server this code does create a window displaying the right information. The problem is that it opens this windows on the system i used to deploy the application and not on the machine requesting the jsp page.
    Question:
    How do you get this window to be displayed on the requesting machine, preferably without using an applet approach?
    Any code examples showing the use of swing elements in jsp pages are welcome.

    I understand the desire to not use an applet. Have you tried an html pop-up? This will create a separate http request through to your server on the user's same session. This allows your server to do the required processing to display the data to the user via html.
    Use the target="_blank" attribute of the anchor tag, or a window.open JavaScript method.

  • Missed event monitor with event reset

    I have pretty simple request for Scom monitoring, but I don’t know how to do it. My application generates an event in custom log with name Mpis. Event level is Informational, Event ID is 10 and source is Mpis. This event is created every
    5 minutes. If application failed, event isn’t created. I have a need to create an alert, if event isn’t created more than one hour and monitor must go into unhealthy state (red). If same event come back, monitor must resolve itself and go back to healthy (green).
    I try doing this with missed event monitor with event reset, but they don’t work as I expected, probably because I use the same event for trigger an alert and resolve an alert. Any idea ?

    There must be something misconfigured. Missed Event Detection -> Windows Event Reset is the correct one.
    Use Event ID 10 and Source Mpis as expression in both Simple Event Expression and Missing Event Expression. in Missing Event Detection, use "Based on fixed simple recurring Schedule" and choose 60 minutes/1 hour.
    I have configured this in my environment, and this works perfectly; if no events are logged within an hour, i get an alert. If i then create the event, the alert Closes.
    www.coretech.dk - blog.coretech.dk

  • Monitor wait events thru OEM

    Hi,
    We have OEM (10.2.0.5) and how to monitor wait events thru OEM and where do we find them? I checked under performance tab and couldn't find.

    Go to: Database Instance > Server Tab > Statistics Management > Automatic Workload Repository
    Click "Run AWR Report" for any time period you want. It looks like Statspack report and has all the wait events in that period.
    Another way is to Go to Performance Tab > Top Activity and click on a session in Top Sessions. It has a summary of waits for that session. You can change the drop down "Show Aggregated Data" to "Show Raw Data" to see breakdown of waits for the session.

  • VB Scripting to monitor application event log based on specific words.

    Hi All,
    I Have written, vb script to monitor application event log based on specific word in the message. when I have included same script in monitor, after running this script at specific time once in day, I am getting run time error in the server, where it
    supposed to run, could you please check the command where I have highlighted in below script.
    Dim VarSize
    Dim objMOMAPI
    Dim objBag
    Set objMOMAPI = CreateObject("MOM.ScriptAPI")
    Set objBag = objMOMAPI.CreateTypedPropertyBag(StateDataType)
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Const CONVERT_TO_LOCAL_TIME = True
    Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
    dtmStartDate.SetVarDate dateadd("n", -1440, now)' CONVERT_TO_LOCAL_TIME
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colLoggedEvents = objWMIService.ExecQuery _
     ("SELECT * FROM Win32_NTLogEvent WHERE Logfile = 'Application' AND " _
     & "EventCode = '100'")
    For Each objEvent in colLoggedEvents
    If InStr(LCase(colLoggedEvents.Message), "Message :Application A3 has been successfully processed for today") Then
    X= "Success"
    end if
    Next
    if X="Success" then
    call objBag.AddValue("State","GOOD")
    call objMOMAPI.Return(objBag)
    wscript.quit()
    Else
    call objBag.AddValue("State","BAD")
    call objMOMAPI.Return(objBag)
    wscript.quit()
    End If

    By programming standards since as long as I can remember the use of the value of a variable to detect its Boolean state has been used.
    Cast your mind back to strongly typed languages, e.g. Pascal.
    I'll cast back to the very early days of the "C" language where all variables could be treated as "bool" without a cast. The is no more strongly type language than "C". "C" practically invented the standards for all modern languages. 
    When I was writin machine language we also used zero as false but many machines only  tested the high bit for truthieness.  The HP machines and Intel allowed a test to aggregate to the sign bit.  Adding that flag to the test alloed tru for
    an numeric value that was non-zero.  A boool test was also used for a negative e switch.  If you study micro language implementation you will find that this hardware design and the companion compiler design is ... well... by design.  It is a
    way of improving the completeness and usefulness of an instruction set.
    Other langauges may require further decoration due to some mistaken desire to be better than perfect. That is like trying to change number theory by renaming addition to be "gunking" and forcing everyone to use multiplication when adding the same number
    more than once.  A Boolean test os a test of the flag bit with to without aggregation.    Even if we test a bit in a word we still mask and aggregate.  It is always the most primitive operation.  It is also the most useful
    operation when you finally realize that it is like an identity in math.
    Use the language features that are designed in. They can help to make code much more flexible and logical.
    By the way, Pascal also treats everything as Boolean when asked to.
    ¯\_(ツ)_/¯

  • Monitoring BizTalk Event Viewer 2006R2

    Hi ,
    In our project, we are using "Schedule" custom adapter in BizTalk for some receive locations and every Friday these schedules should run. 
    But I have got warning message last friday with event id 5740 stating that adapter schedule was changed to next friday.
    Do we have any simple way to monitor BizTalk events getting fired everyday? Also is there a way to customise HAT queries to find out messages required?

    Hi Raghu,
    This code may help you out to monitor event logs
    using System;
    using System.IO;
    using System.Diagnostics;
    public class Test
    public static void Main()
    // check for the event log source on specified machine
    // the Application event log source on MCBcomputer
    if (!EventLog.Exists("Application", "MCBcomputer"))
    Console.WriteLine("The log does not exist!");
    return;
    EventLog myLog = new EventLog();
    myLog.Log = "Application";
    myLog.MachineName = "MCBcomputer";
    Console.WriteLine("There are " + myLog.Entries.Count + " entr[y|ies] in the Application log:");
    foreach (EventLogEntry entry in myLog.Entries)
    Console.WriteLine("\tEntry: " + entry.Message);
    // check for Demo event log source existence
    // create it if it not exist
    if (!EventLog.SourceExists("Demo"))
    EventLog.CreateEventSource("Demo", "Demo");
    EventLog.WriteEntry("AnySource", "writing error to demo log.", EventLogEntryType.Error);
    Console.WriteLine("Monitoring of Application event log began...");
    Console.WriteLine(@"Press 'q' and 'Enter' to quit");
    while (Console.Read() != 'q')
    // Now we will monitor the new entries that will be written.
    // When you create an EntryWrittenEventHandler delegate
    // you identify the method that will handle the event.
    myLog.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);
    // EnableRaisingEvents gets or sets a value indicating whether the
    // EventLog instance receives EntryWritten event notifications.
    myLog.EnableRaisingEvents = true;
    public static void OnEntryWritten(Object source, EntryWrittenEventArgs e)
    Console.WriteLine("written entry: " + e.Entry.Message);
    Thanks
    Abhishek

  • RMI and Swing Events

    Hi,
    I have a problem, integrating an application with RMI and a Client side with swing.
    I have un RMI object that does something, and in any time I want to inform to the client side rmi... I did something like:
    // This is the REmote implementation
    public MyRemoteImpl extends Activatable implements MyRemote{
      EventListenerList listeners;
    // code for activation, etc.......
      public void addListener(MyListener l){
        // add the listener in the list...
      public void fireEvent(String msgEvent){
        // in each listener that is MyListener, .doEvent(String msg)
      // Methods that calls fireEvent...
    // Mylistener interface..
    public MyListener implements EventListener{
      public void doEvent(String msg);
    // The swing client side.
    public MyClient extends JPanel implements MyListener{
      MyRemote rem=null;
      // In the start of ui.. Ido:
      rem.addListener(this);
      public void doEvent(String msg){
        // Puts the message at one component....
    }The problem is that when the doEvent of the Swing side is called, it is executing in the rmid... And the UI is not updated...
    What I do wrong??
    Thanks and Best Regards.

    I wrote an application that does something similar, it receives some event and modifies a JTree accordingly. You should try using the java.awt.EventQueue.invokeLater(Runnable) method. Something like this:
    public void doEvent(String msg) {
        // Determine what changes need to be made
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                // Only the GUI component modification calls need to go here
    }

  • SQL Server monitoring error event log 4001

    hello Experts ,
    We have SCOM 2012 R2 environment ,I have installed SQL SERVER MPs 6.5.0.1 and installed SCOM agent on some of SQL Server. Some of the SQL Server are monitoring working properly not all SQL Server but getting error  for some of SQL Server in event log
    Event :4001
    Management Group: SCOMMgtGroup. Script: Main Module: CPUUsagePercentDataSource.ps1 : 
    Computer Name = 'MHSSCOM01.memnet.org' WMI = 'ComputerManagement11' Service Name = 'MSSQLSERVER' SQL Instance Name = 'MSSQLSERVER'
    Exception calling "Fill" with "1" argument(s): "The user does not have permission to perform this action."Error occured during CPU Usage for SQL Instances data source executing.
    Computer:MHSSCOM01 
    Reason: Exception calling "Fill" with "1" argument(s): "The user does not have permission to perform this action."
    also not getting Database information within the SQL Server instances for these SQL Server within "Instances Summary "
    for resolution ,I have created a Run as account (windows)for SQL monitoring then associated it with Run as profile with SQL Server default account,Discovery account and Monitoring account and distribute it securely to each SQL Server health service object
    .The run as account have  added to local admin group on each SQL server.
    How to resolved the event log error and how to get database information for all instances of sql server.
    Thanks
    RICHA

    Hi,
    It seems like that the action account that run the script does not have enough permissions on the monitored SQL server, I would like to suggest you follow the below link to check your runas account configuration:
    http://blogs.technet.com/b/kevinholman/archive/2010/09/08/configuring-run-as-accounts-and-profiles-in-r2-a-sql-management-pack-example.aspx
    And make sure the action account also have SQL admin account to the SQL server.
    Here is also a link that may be helpful for you:
    http://blogs.technet.com/b/momteam/archive/2014/05/12/kb-event-4001-in-the-operations-manager-log-during-sql-server-2012-monitoring.aspx
    Regards,
    Yan Li
    Regards, Yan Li

  • How can I use java swing class in JSP page design

    I am a new developer in Java server pages. I want to use layout managers available in java swing classes to design the page. Can any body suggest me a way to do this.Is it possible if I do it with servelets.

    So, you want to use layout managers within your JSPs?
    The immediate answer is that "it isn't a good idea". The more considered answer is "tell us what you're up to".
    Are you coding all presentation within a traditional JSP? That is, HTML, customer or library tags and/java scriptlets?
    Or are you building your HTML within your servlets and sending that back to the browser?
    If the first, then you are probably better off either using explicit HTML tables (or the equivalent custom tags) or finding a library that you can use.
    If the second, you can write classes similar to the Swing layout managers that end up being a fancy way of putting elements into an HTML table. We have exactly that in my current environment. I wouldn't recommend rolling your own and I'd tend to leave all that presentation stuff to the JSP.
    In any case, you can't really use the Swing layout managers as they are for an entirely different pradigm.

  • Using Swing Components in JSP

    Hi,
    I regret that I do not have a very specific problem here. However, I am wondering if there is a way to display Swing components, such as a panel, on a web page using JSP. If so, are there any tutorials on such a practice? Or would something like this be included in a general tutorial?
    Thanks,
    Dan

    You'll have to use a JApplet.

  • Process Monitor Diagram Applet in JSP

    Has anyone experienced to use Java Applet in JSP to display the process diagram, just as what you can see in the workflow console. I notice that WF_MONITOR has a getMonitorURL() API which returns a link that leads to Workflow Console, I feel this isn't user friendly. If I could bring what user exactly sees the process diagram in workflow console to Java JSP, it would be superb ...........
    any idea?
    Kun

    All I can think of is that you are using swing and
    including the necessary files via import statements in
    the code. This might cause the applet to run fine with
    the default Netscape JVM. On the other hand, when
    using the jsp:plugin tag the browser is instructed to
    download the Java2 plugin regardless of whether the
    applet will run or not. What I'm saying is that you
    probably don't have the Java2 plugin installed on your
    browser rather you have the necessary jar files in
    your classpath to support Java2. Does that make any
    sense?>
    CliffI don't have a shell CLASSPATH variable, and I'm not sure how to tell what CLASSPATH variable Netscape is using.
    The applet doesn't use Swing as far as I can tell, the code for this applet is at
    http://tmap.pmel.noaa.gov/~callahan/JAVA/map_v3.0/LiveMap_30.java.
    It appears to use only awt for imaging, which I think is considered Java1.
    A bit off topic:
    I have the javaplugin.so which ships with jdk1.3.1_01. However when I look under Edit->Preferences->Navigator->Applications and try to set the plugin used for application/x-java-applet I see that the setting is one for "Unknown - prompt user". Also if I look under Edit->Preferences->Advanced I can see that "Enable Java" is checked and activated but "Enable Java Plugin" is not checked and unavailable (it is greyed-out).
    1) How can I get Netscape to "know about" the plugin I have available in my JRE ?
    2) How can I tell Netscape to use this plugin for all things Java ?
    3) How is it that the applet runs fine when included in a HTML page, even though it appears that my browser's application settings aren't set up to handle applets correctly ?
    4) The Netscape Edit->Preferences->Advanced shows that Java is enabled but the plugin is not. I guess I'm missing something here as I thought that the Java plugin was required for anything Java related to run (such as applets) but this is obviously not so since the applet will run fine if coming from the HTML page.
    A bit perplexed...
    -James

  • A doubt in SWING event handling

    Hi all,
    I'm a beginner in JAVA studying SWING. I learned that if we want to handle an event for a event source(say JButton) we should implement corresponding Event Listener(say ActionListener) .
    I also understood that we should register the Listener with that event source.
    With that knowledge I tried this program
    import javax.swing.*;
    import java.awt.event.*;
    public class SimpleGui2 implements MouseListener,ActionListener {
       SimpleGui2 insGui;
       JButton button= new JButton("Click me");
         public static void main(String[] args) {
              SimpleGui2 gui = new SimpleGui2();
              gui.start();
       public void start() {
            JFrame frame = new JFrame();
            //button.addMouseListener(this);   
            //button.addActionListener(this);
            button.addActionListener(insGui);
            frame.getContentPane().add(button);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(300,300);
            frame.setVisible(true);
       public void actionPerformed(ActionEvent ae) {
            button.setText("Triggered");
       public void mouseClicked(MouseEvent me) {
          button.setText("I have been clicked");
       public void mouseEntered(MouseEvent me) { }
       public void mouseExited(MouseEvent me) { }
       public void mousePressed(MouseEvent me) { }
       public void mouseReleased(MouseEvent me) { }  
    }but It's is not working as I expected.
    or precisely why when we clicked the actionPerformed/mouseClicked method is not invoked ?
    if i change the same with argument "this" it's working .
    I guess "this" refers to current object (which is also of type SimpleGui2 which implemented ActionListener)
    Can any one please clarify me what happens behind the scenes ?
    Thanks in advance

    first of all, you never initialize insGui. YOu just declare it, and never use it.
    SimpleGui2 insGui;However, you dont need it anyways. As you suspected, using 'this' when you add your actionListener is what you need.
    button.addActionListener(insGui);
    Can any one please clarify me what happens behind the scenes ?Well my professor always said it was 'black magic'. All I know is that you click a button with an event listener, and an event is fired doing whatever you want it to do. For example, if I want my event to print "Hey" then when I click the button, "Hey" is printed. Simple enough eh? You will probably find a better answer using Google though. It's amazing.

Maybe you are looking for