Serious Problem with Applets ...
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Saturday, September 8, 2001 11:12 PM

Hi Guy's !!! Below here is a piece of code :- import javax.swing.*; public class AppletTest extends JApplet { public void init() { //Applet Initialization //A user is added to the Database System.out.println("Event fired in init ..."); } public void start() { System.out.println("Event fired in start ..."); } public void stop() { System.out.println("Event fired in stop ..."); } public void destroy() { //Contains code that passes the username to the servlet which then DELETES    More>>

Hi Guy's !!!

Below here is a piece of code :-



import javax.swing.*;

public class AppletTest extends JApplet
{
public void init()
{
//Applet Initialization
//A user is added to the Database
System.out.println("Event fired in init ...");

}

public void start()
{
System.out.println("Event fired in start ...");
}

public void stop()
{
System.out.println("Event fired in stop ...");
}

public void destroy()
{
//Contains code that passes the username to the servlet which then DELETES that user from the Database.Thus it's important that the destroy() be invoked when the browser is closed .
System.out.println("Event fired in destroy ...");
}
}



Have tried out a small piece of code using "servletrunner" for testing so that i can view the output at the dos prompt.Through the destroy() a value is passed to the server and for confirmation that this event has for sure taken place a message in printed in the doPost() of the servlet.


BASICALLY,A USER NEEDS TO BE ADDED TO THE DATABASE WHEN THE INIT() IS FIRED AND THAT USER NEEDS TO BE DELETED FROM THE DATABASE WHEN THE DESTROY() IS FIRED().However,it does'nt happen as desired.


Also,need to take care of the other events that get fired when events such as :
1.)A New Browser is opened.
2.)When the Back Button is pressed
3.)When the Forward Button is pressed
4.)When the Refresh Button is pressed
5.)When a New URL is mentioned in the browser over the existing URL
6.)When the Close Button is pressed.


ALSO,NEED TO TAKE CARE THAT THE APPLET METHODS IN WHICH CODE IS PLACED TO ADD AND DELETE USERS FROM THE DATABASE ARE FIRED PROPERLY IN BOTH INTERNET EXPLORER & NETSCAPE .


FINALLY,THE END RESULT OF ALL THESE EVENTS FIRED IN BOTH BROWSERS SHOULD LEAVE THE DATABASE IN A CONSISTENT STATE .


Guy's i'm not sure what i should do to handle this properly since,the destroy() too does'nt get invoked on closing the browser .That was what happened in the example above.At the same time the same code above fired the destroy() when used along with the applet tag instead of the embed tag.But,i have got to use the "embed" tag since the application contains swing components.


What should in do in this situation.Pls give me ur suggestions.


Thanks Guys !!!

   <<Less

Re: Serious Problem with Applets ...

Posted By:   John_Zukowski  
Posted On:   Monday, September 10, 2001 12:25 PM

There is no guarantee that the method is called in the applet. If the browser crashes or the user's net connection disconnects, it won't be called.


The behavior you desire should be programmed into the servlet, when the session times out for instance. That is already addressed in the servlet FAQ.

Re: Serious Problem with Applets ...

Posted By:   sam_pitroda  
Posted On:   Monday, September 10, 2001 10:45 AM

just a couple of days ago, someone answered a similar question recommending that we should use stop() instead of destroy() as it is the only method which gets called correctly both in IE and Netscape. There was a nice chart that was published but I cant find it now. If I find, I will let you know.
About | Sitemap | Contact