EEM Applet Using IPSLA ED
After reading the docs on the IPSLA ED, I decided to write the following applet just to see if I understand how to use it.
ip sla responder
ip sla enable reaction-alerts
ip sla 1
udp-jitter 210.210.210.1 16384 num-packets 100 interval 20
request-data-size 172
tos 176
ip sla schedule 1 start-time now life forever
ip sla reaction-configuration 1 react jitterDSAvg threshold-value 35 30 threshold-type consecutive 3
ip sla reaction-configuration 1 react jitterSDAvg threshold-value 35 30 threshold-type consecutive 3
ip sla reaction-configuration 1 react rtt threshold-value 225 200 threshold-type consecutive 3
ip sla reaction-configuration 1 react packetLossSD threshold-value 2 1 threshold-type consecutive 3
ip sla reaction-configuration 1 react packetLossDS threshold-value 2 1 threshold-type consecutive 3
event manager applet VoIP-Test-Alert
description "Send syslog msg if rrt delay > 225 or jitter > 35 ms or packet loss > 2%”
event tag e1 ipsla operation-id 1 reaction-type jitterDSAvg
event tag e2 ipsla operation-id 1 reaction-type jitterSDAvg
event tag e3 ipsla operation-id 1 reaction-type rtt
event tag e4 ipsla operation-id 1 reaction-type packetLossSD
event tag e5 ipsla operation-id 1 reaction-type packetLossDS
trigger occurs 1 period 360
correlate event e1 or event e2 or event e3 or event e4 or event e5
action 1.0 if $_ipsla_measured_threshold_value gt $_ipsla_threshold_rising
action 2.0 syslog priority notification msg "$_ipsla_react_type = $_ipsla_measured_threshold_value is over threshold $_ipsla_threshold_rising to destination $_ipsla_dest_ip_addr”
action 3.0 end
Seems to work but I cannot figure whether using applets if it is possible to expend this by having another applet realize that all my reactions for IP SLA 1 are under their falling theshold and thus issue a syslog message that all is A-OK.
thx in advance for any suggestions.
Thank you. That would do it for that but now I have another issue.
I want to expand my applet so only one applet would be all that is needed to alert for ip sla tests to multiple targets so I tried yesterday to expand my applet to somethink like the following:
event manager applet VoIP-Test-Alert
description "Send syslog msg if rrt delay > 225 or jitter > 35 ms or packet loss > 2%”
event tag e1 ipsla group-name 1 reaction-type jitterDSAvg
event tag e2 ipsla group-name 1 reaction-type jitterSDAvg
event tag e3 ipsla group-name 1 reaction-type rtt
event tag e4 ipsla group-name 1 reaction-type packetLossSD
event tag e5 ipsla group-name 1 reaction-type packetLossDS
trigger occurs 1 period 360
correlate event e1 or event e2 or event e3 or event e4 or event e5
I then used the ip sla schedule command to put ip sla operation-id 1 into schedule group id 1. But when I tested, I got the Ip SLA threshold exceeded syslog messages but my applet failed to trigger.
I am not understading something here in regards to IP SLA ED use of group-name. In IP SLA schedule group ids are integers while in the applet group-name are strings. Thus I suspect I am not correctly creating the ip sla group correctly.
Thanks in advance again for any help.
Similar Messages
-
Hi,
I have a scenario where i would like to execute a EEM applet for running an ip sla event when othe ip sla event is up. Just to summarize an IP sla event success should trigger anothe IP sla event. I have tried the two options below but was not able to find any debug logs.
ip sla 10
icmp-jitter x.x.x.x source-ip x.x.x.x num-packets 10
frequency 30
ip sla schedule 10 life forever start-time now
ip sla 20
icmp-jitter x.x.x.x source-ip x.x.x.x num-packets 10
frequency 30
event manager applet SLA
event timer cron cron-entry "5 * * * *"
event ipsla operation-id 10 reaction-type timeout
action 10 if $_ipsla_condition eq "Occurred"
action 15 cli command "enable"
action 20 cli command "configure term"
action 25 cli command "no ip sla schedule 20 life forever start-time now"
action 30 else
action 35 cli command "enable"
action 40 cli command "configure term"
action 45 cli command "ip sla schedule 20 life forever start-time now"
action 50 end
OR
ip sla 10
icmp-jitter x.x.x.x source-ip x.x.x.x num-packets 10
frequency 30
ip sla schedule 10 life forever start-time now
ip sla 20
icmp-jitter y.y.y.y source-ip y.y.y.y num-packets 10
frequency 30
track 1 ip lsa reachability
event manager applet SLA-1
event timer cron cron-entry "5 * * * *"
event track 1 state up
action 10 cli command "enable"
action 20 cli command "conf t"
action 30 cli command "ip sla schedule 20 life forever start-time now"
action 40 cli command "end"
event manager applet SLA-2
event timer cron cron-entry "5 * * * *"
event track 1 state down
action 10 cli command "enable"
action 20 cli command '' conf t"
action 30 cli command "no ip sla schedule 20 life forever start-time now"
action 40 cli command "end"
Regards,
Sathvik K VHi Joseph,
I would like to run the script pasted below during buisness hours(9am to 6pm). When two if conditions are used is it the first condition is checked and if that passes it will check the second condition.
event manager applet APP-1
event track 1 state up
action 001 cli command "enable"
action 002 cli command "show clock"
action 003 regexp "([0-9]+):[0-9]:[0-9]" $_cli_result match hour
action 004 if $hour ge 9
action 005 cli command "conf t"
action 006 cli command "ip sla 2"
action 007 cli command "icmp-echo x.x.x.x source-ip x.x.x.x"
action 008 cli command "frequency 30"
action 009 cli command "ip sla schedule 2 life forever start-time now"
action 010 end
action 011 if $hour le 18
action 012 cli command "ip sla 2"
action 013 cli command "icmp-echo x.x.x.x source-ip x.x.x.x"
action 014 cli command "frequency 30"
action 015 cli command "ip sla schedule 2 life forever start-time now"
action 016 end
event manager applet APP-2
event track 1 state down
action 10 cli command "enable"
action 20 cli command "conf t"
action 30 cli command "no ip sla 2"
action 40 cli command "end"
Regards,
Sathvik -
EEM Applet Problem With: event syslog pattern ".*" priority 2
I went to create a EEM applet that would be invoked whenever any syslog message of priority 0-2 was invoked. I figured the following event statement would work
event syslog pattern ".*" priority 2
I never really used the priority optional argument before but thought I understood from the docs that messages at or numerically lower than the specified level are matched.
Well it doesn't seem to work as documented. Seems to me that only messages at the specified level are beng matched and not messages numerically lower than the specified level.
Anyway I did what I wanted differently but wanted to post this in case this is a bug in the syslog ed.Actually, it's a problem with the documentation. The priority option only matches the specified severity. What you could do is adjust pattern to do this:
event syslog pattern "*-[012]-" -
EEM applet to reload router after ip is unreachable over time
Hi
I am trying to create an EEM applet that will track the reachability of a group of IP addresses. The condition needs to be as followed:
If the IP addresses become unreachable for about an 1 hour 15 minutes then reload the router. I have looked at the delay command using the IP SLA option but it only delays up to 180 seconds. Any Ideas?The applet that tracks your IP SLA objects (I'm guessing you have a tracked object that tracks a list of other objects) should configure another timer applet that counts down the time you want. For example:
event manager applet track-down event track 3 state down action 1.0 cli command "enable" action 2.0 cli command "config t" action 3.0 cli command "event manager applet countdown" action 3.1 cli command "event timer countdown time 4500" action 3.2 cli command "action 1.0 reload" action 4.0 cli command "end"!event manager applet track-up event track 3 state up action 1.0 cli command "enable" action 2.0 cli command "config t" action 3.0 cli command "no event manager applet countdown" action 4.0 cli command "end" -
As i am going to configure EEM applet for TFTP backup on my cisco production device, I want to know weather there are any drawbacks of EEM applet like resources consumtion etc.
Hi Joseph,
I am going to use below applet for Automatic TFTP backup.
action 1 cli command "enable"
action 2 cli command "configure terminal"
action 3 cli command "file prompt quiet"
action 4 cli command "end"
action 5 cli command "copy running-config tftp://tftp-server/router-confg"
action 6 cli command "configure terminal"
action 7 cli command "no file prompt quiet"
action 8 cli command "end"
Do I need to take any precautions during this applet configuration ? -
Problem in loading an applet using JRE 1.5
Hi,
I have an applet which is working fine under JRE 1.4, but the same applet failing to load by using JRE 1.5
Problem Description:
1. The images in the applet fails to load using JRE 1.5
2. The Username and Password text box are also failing to initialize.
Can anyone help me out in this.
Is there any code changes required ?I wonder if you have the same problem as me... Maybe we can find a solution for us both, no need for me to open a new thread for this topic then...
I wrote an applet using Swing and compiled it using JavaSDK 1.4.x. I also installed the 1.4.x JRE for both of my test browsers. In Mozilla 1.1 the applet displays properly all the time. In IE6 SP1 it sometimes works as intended but sometimes the applet simply stops working, as per my Java Console somewhere after invoking the "start" method. Parts of the applet simply become gray and when I resize it - I have a JFrame in my applet - the whole JFrame becomes gray and does not respond to input nor it redraws itself. Shutting down IE does not close the JFrame(although the java console reports normal program termination and cleanup) and the only way to close it is through the task manager. I am using Windows 98SE btw.
Does it sound similiar to your problem? It happens ONLY with IE, not with Mozilla. Anybody has an idea on what it could be? I doubt there's an error in my code... -
Html file to run an Applet using swings in 1.4.1 or 1.3.1
Can anyone send me an html document to launch the applet in a browser. I have very basic html, but I need one that uses the appropriate plug-in and that has parameters such as height, width, etc. My applet uses tabbed panes, dialog boxes and comboboxes. It works well with appletviewer, but does not work in IE or Netscape.
Thank you for your help
here is what I am using which does does show anything but a grey screen
<HTML>
<HEAD>
<TITLE>
CIS 602 Semister Project
</TITLE>
</HEAD>
<BODY>
<BR>
<H3>
<CENTER>
Swing
</CENTER>
</H3>
<H3>
<BR><BR>
<P><H3>
<CENTER>
<BR><BR>
<P><h2>
Structured Problem Solving Strategy
</h2>
<blockquote>
<!--"CONVERTED_APPLET"-->
<!-- CONVERTER VERSION 1.1 -->
<SCRIPT LANGUAGE="JavaScript"><!--
var info = navigator.userAgent; var ns = false;
var ie = (info.indexOf("MSIE") > 0 && info.indexOf("Win") > 0 && info.indexOf("Windows 3.1") < 0);
//--></SCRIPT>
<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
var ns = (navigator.appName.indexOf("Netscape") >= 0 && ((info.indexOf("Win") > 0 && info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));
//--></SCRIPT></COMMENT>
<SCRIPT LANGUAGE="JavaScript"><!--
if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "570" HEIGHT = "500" codebase="http://java.sun.com/products/plugin/1.1.2/jinstall-112-win32.cab#Version=1,1,2,0"><NOEMBED><XMP>');
else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.4.2" java_CODE = "semiclient.class" WIDTH = "570" HEIGHT = "500" pluginspage="http://java.sun.com/products/plugin/1.1.2/plugin-install.html"><NOEMBED><XMP>');
//--></SCRIPT>
<APPLET CODE = "semiclient.class" WIDTH = "570" HEIGHT = "500" ></XMP>
<PARAM NAME = CODE VALUE = "semiclient.class" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4.2">
</APPLET>
</NOEMBED></EMBED></OBJECT>
<!--
<APPLET CODE = "semiclient.class" WIDTH = "570" HEIGHT = "500" >
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</Center>
<BLOCKQUOTE><PRE>
</PRE></BLOCKQUOTE>
</H3>
<BLOCKQUOTE><PRE>
</PRE></BLOCKQUOTE>
</H3>
</BODY></HTML>Try this:
<HTML>
<HEAD>
<TITLE>CIS 602 Semister Project</TITLE>
</HEAD>
<BODY>
<CENTER><H3>Swing</H3></CENTER><CENTER><H2>Structured Problem Solving Strategy</H2></CENTER>
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="750"
height="575"
align="baseline"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_0-win.cab">
<PARAM NAME="code" VALUE="full.qualified.ClassName">
<PARAM NAME="codebase" VALUE="path/to/your/class/files/or/archive/">
<PARAM NAME="archive" VALUE="nameOfJarWhichContainsClassFiles.jar">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
<PARAM NAME="scriptable" VALUE="false">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.4"
width="750"
height="575"
align="baseline"
code="full.qualified.ClassName"
codebase="path/to/your/class/files/or/archive/"
archive="nameOfJarWhichContainsClassFiles.jar"
pluginspage="http://java.sun.com/products/plugin/1.4/plugin-install.html">
<NOEMBED>
No Java 2 SDK, Standard Edition v 1.4 support for APPLET!!
</noembed>
</embed>
</COMMENT>
</OBJECT>
</BODY>
</HTML> -
Japanese text display problems in applet using plugin
Hi,
We've been beating our heads against the wall on this one for quite some time, so any help would be greatly appreciated.
Our product uses a third party applet (Kavachart from Visual Engineering) to display graphical statistics from our database. We are currently localizing our product to support english and japanese. With Japanese enabled, all pages use euc-jp encoding. The problem we are running into is in the display of japanese text inside this applet in IE 5 and NS 4.7x when using the java plugin (1.3 or 1.4). If the default jre of the browsers are used, the text in the applet renders fine.
On a suggestion from the supprot folks at Visual Engineering, I modified our code to set the defaultFont parameter on the applet to "serif, 14, 1". With this set, the text in the applet renders ok in IE, but NS on windows and unix is still broken. Given that we are doing all these tests on machines running a native japanese OS, it's not even clear to me why setting the defaultFont should even be required, but at this point, I'll take anything :-)
Has anyone else run into this and either solved it or proven that a solution is not feasible? I'm at my wits end here....
Thanks in advance,
Mark Evangelisto
Synchronicity Inc.If you are using different java plugin, you need to install the international version of the JRE; otherwise, some characters may not be able to display correctly since some of the properties files are missing.
As for Visual Engineering's suggestion. I don't know why they tell you to set the default font on the applet because it may cause the browser to use the font specified. Your applet works on IE because it will try to use the best font to match the web page's content. For NS anything less then 6.0 (technology based on Mozilla), they never display web page correctly especially if you did what VE suggest.
If you are running the applet on the native langauge OS with the international version of the JRE installed, the applet should display correctly without setting the default font. If it is not the native langauge OS, first you need to install the international version of the JRE and have the fonts that are able to display the language the applet use. -
Writing new HTML to a page from an applet using LiveConnect, 1.3.1 Plug-i
Has anyone been able to successfully replace a page with an applet with the dynamically generated HTML from an applet using LiveConnect and Plugin 1.3.1 in Netscape 6.2 or IE?
The following works fine without plugin or with 1.4.0 beta3 plugin.
Here is the code that I use without plugin:
JSObject windowObject = JSObject.getWindow(this);
JSObject documentObject = (JSObject) windowObject.getMember("document");
documentObject.call("close",null);
documentObject.call("open",null);
String anArray1[] = {null};
anArray1[0] ="some HTML here";
documentObject.call("write", anArray1);
documentObject.call("close",null);
Here is the code that I use with 1.4.0 plugin:
JSObject windowObject = JSObject.getWindow(this);
JSObject documentObject = (JSObject) windowObject.getMember("document");
String anArray1[] = {null};
anArray1[0] ="some HTML here";
documentObject.call("write", anArray1);
When I try to use anyone of the above using plugin 1.3.1, the browser either hangs or plugin generates runtime error. What is the correct way of writing to a document object? Or what is the way that works for 1.3.1 plugin?Hi,
I am doing this in my applet to replace the page containing the applet with the new content. I tested that extensively with Netscape 4.7 and IE 5.5+. Definitely works if you are using Java Plug-In 1.3.1_02. Does not work well in Netscape 6.2.
protected void setPageContent(final String newContent) {
final JSObject window = JSObject.getWindow(this);
final JSObject document = (JSObject) window.getMember("document");
new Thread( new Runnable() {
public void run() {
document.call("clear", null);
document.call("write", new String[]{newContent});
try {
document.call("close", null);
} catch (JSException ignored) {
} ).start(); -
Please give me an exemple of an applet using a swing object.
Please give me an exemple of an applet using a swing object.thank you.
My problen is that the swing object do not appear in
my applet. They appear only if i invoque the repaint
methode.use JApplet, since awt components are heavyweight, and swing components are lightwieght, then your swing components get over painted with aplets background or something.
anyhow, in your applet you may create JFrame, that would be swing component and if you set it visible, then it will be even visible.
they say that mixing swing and awt is not good idea, especially when you don't know what you're doing (which might be true in your case)
so try to migrate your app from AWT based stuff to SWING based stuff, or write your own AWT components that do the job whih you needed swing component for at the first place.
but if you need to mix awt and swing, then i thing that you should not paint the fole area of applet in applets paint method -- but here i'm not sure, never mixed 'em.
so you might try to create an applet which paint() method you leave empty and to which you add some JComponent*.
and see what happens, maybe this JComponent will be visible.
* -- JComponent is most likely just gray, you might want to add some subclass of it -- JButton, JTextField, JSomethingElse. -
Can you please tell me how can i change the parameter of Applet using Aspec
Respect Members
Can we apply Aspectwerkz on Applet? In our project we have to
change the method parameters before its execution(Around Advice) , can we do this in applet using Aspectwerkz?
Can you please tell me how can i change the parameter of Applet using Aspectwerkz or AspectJ ?
I did it by for Java Application using the AspectJ And Aspectwerkz But not able to do for Applet.
For Applet I Am setting the parameter in JAVA plug in for Aspectwerkz e.g. -Xdebug -Xrunaspectwerkz -Xbootclasspath & path for xml file in which pointcut is defined.
If you any Friend working on it or any author who might be helpfull for me please Forward this mail to him/her
THANKs in Advance
[email protected]hello rodale, what you're seeing is probably a side effect of firefox not being able to save certain preferences into its profile folder.
go to ''firefox > help > troubleshooting information'', click on ''profile folder/show folder'' and close all firefox windows afterwards. a windows explorer window should open up - in there delete the file named '''user.js'''.
in case this didn't solve the issue yet please also refer to [[How to fix preferences that won't save]]. -
Hi,
I'm trying to run a chat application using RMI technology. Actually, this wasn't created from the scratch. I got this one from from the cd that comes with the book I bought and I did some refinements on it to suit what I wanted to:
These are the components of the chat application:
1. RApplet.html - invokes the applet
html>
<head>
<title>Sample Applet Using Dialog Box (1.0.2) - example 1</title>
</head>
<body>
<h1>The Sample Applet</h1>
<applet code="RApplet.class" width=460 height=160>
</applet>
</body>
</html>
2. RApplet.java - Chat session client applet.
import java.rmi.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import java.rmi.server.*;
//import ajp.rmi.*;
public class RApplet extends Applet implements ActionListener {
// The buttons
Button sendButton;
Button quitButton;
Button startButton;
Button clearButton;
// The Text fields
TextField nameField;
TextArea typeArea;
// The dialog for entering your name
Dialog nameDialog;
// The name the server knows us as
String privateName;
// The name we want to be known as in the chat session
String publicName;
// The remote chats erver
ChatServer chatServer;
// The ChatCallback
ChatCallbackImplementation cCallback;
// The main Chat window and its panels
Frame mainFrame;
Panel center;
Panel south;
public void init() {
// Create class that implements ChatCallback.
cCallback = new ChatCallbackImplementation();
// Create the main Chat frame.
mainFrame = new Frame("Chat Server on : " +
getCodeBase().getHost());
mainFrame.setSize(new Dimension(600, 600));
cCallback.displayArea = new TextArea();
cCallback.displayArea.setEditable(false);
typeArea = new TextArea();
sendButton = new Button("Send");
quitButton = new Button("Quit");
clearButton = new Button("Clear");
// Add the applet as a listener to the button events.
clearButton.addActionListener(this);
sendButton.addActionListener(this);
quitButton.addActionListener(this);
center = new Panel();
center.setLayout(new GridLayout(2, 1));
center.add(cCallback.displayArea);
center.add(typeArea);
south = new Panel();
south.setLayout(new GridLayout(1, 3));
south.add(sendButton);
south.add(quitButton);
south.add(clearButton);
mainFrame.add("Center", center);
mainFrame.add("South", south);
center.setEnabled(false);
south.setEnabled(false);
mainFrame.show();
// Create the login dialog.
nameDialog = new Dialog(mainFrame, "Enter Name to Logon: ");
startButton = new Button("Logon");
startButton.addActionListener(this);
nameField = new TextField();
nameDialog.add("Center", nameField);
nameDialog.add("South", startButton);
try {
// Export ourselves as a ChatCallback to the server.
UnicastRemoteObject.exportObject(cCallback);
// Get the remote handle to the server.
chatServer = (ChatServer)Naming.lookup("//" + "WW7203052W2K" +
"/ChatServer");
catch(Exception e) {
e.printStackTrace();
nameDialog.setSize(new Dimension(200, 200));
nameDialog.show();
* Handle the button events.
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(startButton)) {
try {
nameDialog.setVisible(false);;
publicName = nameField.getText();
privateName = chatServer.register(cCallback, publicName);
center.setEnabled(true);
south.setEnabled(true);
cCallback.displayArea.setText("Connected to chat server as: " +
publicName);
chatServer.sendMessage(privateName, publicName +
" just connected to server");
catch(Exception ex) {
ex.printStackTrace();
else if (e.getSource().equals(quitButton)) {
try {
cCallback.displayArea.setText("");
typeArea.setText("");
center.setEnabled(false);
south.setEnabled(false);
chatServer.unregister(privateName);
nameDialog.show();
catch(Exception ex) {
ex.printStackTrace();
else if (e.getSource().equals(sendButton)) {
try{
chatServer.sendMessage(privateName, typeArea.getText());
typeArea.setText("");
catch(Exception ex) {
ex.printStackTrace();
else if (e.getSource().equals(clearButton)) {
cCallback.displayArea.setText("");
public void destroy() {
try {
super.destroy();
mainFrame.setVisible(false);;
mainFrame.dispose();
chatServer.unregister(privateName);
catch(Exception e) {
e.printStackTrace();
3. Chatcallback.java - interface used by clients to connect to the server.
import java.rmi.*;
public interface ChatCallback extends Remote {
public void addMessage(String publicName,
String message) throws RemoteException;
4. ChatcallbackImplementation.java - implements Chatcallback interface.
import java.rmi.*;
import java.io.*;
import java.awt.event.*;
import java.awt.*;
public class ChatCallbackImplementation implements ChatCallback {
// The buttons
// The Text fields
TextArea displayArea;
public void addMessage(String publicName,
String message) throws RemoteException {
displayArea.append("\n" + "[" + publicName + "]: " + message);
5. Chatserver.java - interface for the chat server.
import java.rmi.*;
import java.io.*;
public interface ChatServer extends Remote {
public String register(ChatCallback object,
String publicName) throws RemoteException;
* Remove the client associated with the specified registration string.
* @param registeredString the string returned to the client upon registration.
public void unregister(String registeredString) throws RemoteException;
* The client is sending new data to the server.
* @param assignedName the string returned to the client upon registration.
* @param data the chat data.
public void sendMessage(String registeredString, String message) throws RemoteException;
6. ChatServerImplementation.java - implements Chatserver interface.
import java.rmi.*;
import java.util.*;
import java.rmi.server.*;
import java.io.*;
* A class that bundles the ChatCallback reference with a public name used
* by the client.
class ChatClient {
private ChatCallback callback;
private String publicName;
ChatClient(ChatCallback cbk, String name) {
callback = cbk;
publicName = name;
// returns the name.
String getName() {
return publicName;
// returns a reference to the callback object.
ChatCallback getCallback() {
return callback;
public class ChatServerImplementation extends UnicastRemoteObject
implements ChatServer {
// The table of clients connected to the server.
Hashtable clients;
// Tne number of current connections to the server.
private int currentConnections;
// The maximum number of connections to the server.
private int maxConnections;
// The output stream to write messages to.
PrintWriter writer;
* Create a ChatServer.
* @param maxConnections the total number if connections allowed.
public ChatServerImplementation(int maxConnections) throws RemoteException {
clients = new Hashtable(maxConnections);
this.maxConnections = maxConnections;
* Increment the counter keeping track of the number of connections.
synchronized boolean incrementConnections() {
boolean ret = false;
if (currentConnections < maxConnections) {
currentConnections++;
ret = true;
return ret;
* Decrement the counter keeping track of the number of connections.
synchronized void decrementConnections() {
if (currentConnections > 0) {
currentConnections--;
* Register with the ChatServer, with a String that publicly identifies
* the chat client. A String that acts as a "magic cookie" is returned
* and is sent by the client on future remote method calls as a way of
* authenticating the client request.
* @param object The ChatCallback object to be used for updates.
* @param publicName The String the object would like to be known as.
* @return The actual String assigned to the object for removing, etc. or
* null if the client could not register.
public synchronized String register(ChatCallback object, String publicString) throws RemoteException {
String assignedName = null;
if (incrementConnections()) {
ChatClient client = new ChatClient(object, publicString);
assignedName = "" + client.hashCode();
clients.put(assignedName, client);
out("Added callback for: " + client.getName());
return assignedName;
* Remove the client associated with the specified registration string.
* @param registeredString the string returned to the client upon registration.
public synchronized void unregister(String registeredString) throws RemoteException {
ChatCallback cbk;
ChatClient sender;
if (clients.containsKey(registeredString)) {
ChatClient c = (ChatClient)clients.remove(registeredString);
decrementConnections();
out("Removed callback for: " + c.getName());
for (Enumeration e = clients.elements(); e.hasMoreElements(); ) {
cbk = ((ChatClient)e.nextElement()).getCallback();
cbk.addMessage("ChatServer",
c.getName() + " has left the building...");
else {
out("Illegal attempt at removing callback (" + registeredString + ")");
* Sets the logging stream.
* @param out the stream to log messages to.
protected void setLogStream(Writer out) throws RemoteException {
writer = new PrintWriter(out);
* The client is sending new message to the server.
* @param assignedName the string returned to the client upon registration.
* @param data the chat data.
public synchronized void sendMessage(String registeredString, String message) throws RemoteException {
ChatCallback cbk;
ChatClient sender;
try {
out("Recieved from " + registeredString);
out("Message: " + message);
if (clients.containsKey(registeredString)) {
sender = (ChatClient)clients.get(registeredString);
for (Enumeration e = clients.elements(); e.hasMoreElements(); ) {
cbk = ((ChatClient)e.nextElement()).getCallback();
cbk.addMessage(sender.getName(), message);
else {
out("Client " + registeredString+ " not registered");
catch(Exception ex){
out("Exception thrown in newData: " + ex);
ex.printStackTrace(writer);
writer.flush();
* Write s string to the current logging stream.
* @param message the string to log.
protected void out(String message){
if(writer != null){
writer.println(message);
writer.flush();
* Start up the Chat server.
public static void main(String args[]) throws Exception {
try {
// Create the security manager
System.setSecurityManager(new RMISecurityManager());
// Instantiate a server
ChatServerImplementation c = new ChatServerImplementation(10);
// Set the output stream of the server to System.out
c.setLogStream(new OutputStreamWriter(System.out));
// Bind the server's name in the registry
Naming.rebind("//" + args[0] + "/ChatServer", c);
c.out("Bound in registry.");
catch (Exception e) {
System.out.println("ChatServerImplementation error:" +
e.getMessage());
e.printStackTrace();
Using my own machine (connected to a network), I tried to test this one out by setting mine as the server and also the client. I did the following:
1. Compile the source code.
2. Use rmic to generate the skeletons and/or stubs from the ChatCallbackImplementation and ChatServerImplementation.
3. Start the rmiregistry with no CLASSPATH
4. Start the server successfully.
5. Start the applet using the AppletViewer command.
It worked fined.
The problem is when I ran the applet using the browser, IE explorer, the dialog boxes, frame and buttons did appear. I was able to do the part of logging on. But after that, the applet seemed to have hang. No message appeared that says I'm connected (which appeared using the appletviewer). I clicked the send button. No response.
I double-checked my classpath. I did have my classpath set correctly. I'm still trying to figure out the problem. Up to now, I don't have any clue what it is.
I will appreciate much if someone can help me figure what's could have possibly been wrong ....
Thanks a lot ...Hi Domingo,
I had a similar problem running applet/rmi with IE.
Looking in IE..view..JavaConsole error messages my applet was unable to find java.rmi.* classes.
I checked over java classes in msJVM, they're not present.
( WinZip C:\WINDOWS\JAVA\Packages\9rl3f9ft.zip and others from msVM installed )
( do not contain the java.rmi.* packages )
I have downloaded and installed the latest msJVM for IE5. ( I think its included in later versions)
@http://www.objectweb.org/rmijdbc/RJfaq.html I found ref to rmi.zip download to provide
these classes. I couldn't get the classes from the site but I managed to find a ref to IBM
site @http://alphaworks.ibm.com/aw.nsf/download/rmi which had similar download.
The download however didn't solve my problems. I was unable to install rmi.zip with
RmiPatch.exe install.
I solved this by extracting the class files from rmi.zip and installing them at C:\WINDOWS\JAVA\trustlib ( msJVM installation trusted classes lib defined in
registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Java VM\TrustedLibsDirectory )
This solved the problem. My rmi/applet worked.
Hope this helps you.
Chris
([email protected]) -
Memory leak with 1.6.0_07 in applet using Swing
Java Plug-in 1.6.0_07
Using JRE version 1.6.0_07 Java HotSpot(TM) Client VM
Windows XP - SP2
I have a commercial application that has developed a memory leak with the introduction of the latest plugin. The applets chew up memory and eventually freeze. They did not before. Using jvisualm I see a build up of native arrays, primarily int[][] and char[]. I'm still investigating. Anyone have a similar experience?
The Applet uses a swing interface, uses buffered images and swing timers, and regularly performs http connections to the server which result in actions via the SwingUtil.invokeLater() method.I am Using Internet Explorer Browser Version 6.0.Huge security hole.
Its not throwing Error / Exception Wrap a try/catch at the highest level possible.
Catch 'Throwable'. And log/display it somewhere. -
Displaying java applet using webseal authentication
Hi all,
i'm facing a problem about displaying Java applet using Webseal junction for accessing an application Server based on Websphere.
I've defined a webseal ACL on accessing a http url that contains link to Java applet: after webseal authentication, the homepage is loaded; in the home page are presented links to java applet, but when I try to load these applets, it seems not working.
If I load the same applets without Webseal authentication, it seems working.
Is there any sort of configuration to make for applet regarding Webseal?
Thanks in advance
DaniloHi all,
i'm facing a problem about displaying Java applet using Webseal junction for accessing an application Server based on Websphere.
I've defined a webseal ACL on accessing a http url that contains link to Java applet: after webseal authentication, the homepage is loaded; in the home page are presented links to java applet, but when I try to load these applets, it seems not working.
If I load the same applets without Webseal authentication, it seems working.
Is there any sort of configuration to make for applet regarding Webseal?
Thanks in advance
Danilo -
Problem with access JSF applet using javascript
Can someone help me!
I'm using a applet in jsf page, and i'm trying to access this applet using a javascript.
Here is the applet code
<jsp:plugin code="DoAction.class" codebase="." height="400" hspace="10" jreversion="1.5" type="applet" vspace="50" width="100" name="myApp"/>
Here is the javascript
function printReturn()
var a = document.myApp.returnString();
alert(a);
"returnString" is the method in applet which simply return a string
But it doesn't work, it works well when i'm using this applet in JSF
<applet code="DoAction.class" width="100" height="50" name="myApp" ></applet>
Unfortunately it's depricated!
Please tell me what is the solution....Thank You for replying.
I'm trying to call applet method using JavaScript.
It works when i'm using below apllet tag.
<applet code="DoAction.class" width="100" height="50" name="myApp" ></applet>
But it's deprecated
It doesn't work for below applet tag
<jsp:plugin code="DoAction.class" codebase="." height="400" hspace="10" jreversion="1.5" type="applet" vspace="50" width="100" name="myApp"/>
This is my javascript
<script type="text/javascript">
function setSearch()
var a = document.myApp.returnString();
alert(a);
</script>
Maybe you are looking for
-
Problem in automated background scheduling
Hi All, I have a program for posting the document. In qlty server it is automatically schedule for 5 min. I have trasported the same program to production with same 5min scheduling. The file is stored in th FTP\152.4xxxxxxx path. This same path is u
-
I have 55,000 images organized into about 1700 events. The only reasonable way to view my library is using events in iPhoto where each event has one image That still leaves 1700 images to sort through but that is a lot easier than 55,000 images. In
-
I'd like to keep my .muse files in the Creative Cloud folder so they will be accessible from anywhere, and always backed up. But I have many hundreds of links to image assets etc, and am worried that if I move the Muse file to the CC folder the links
-
How did I get all the duplicates in my iTunes and how do i get rid of them!!
1000 duplicates in itunes. How do I fix that? ...and how did it happen.?
-
Do I need firewall/antivirus/spyware programs on a mac?
I hope this is in the right place. Can anyone tell me if it is necessary to have any sort of anti-virus software, spyware software and/or extra firewall installed on a mac, and if so, which ones? I've been trying to research the matter and I keep com