wood burning stoves*
The moose likes Applets and the fly likes Need urgent Help - Browser is hanging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Need urgent Help - Browser is hanging" Watch "Need urgent Help - Browser is hanging" New topic
Author

Need urgent Help - Browser is hanging

Sam Cala
Ranch Hand

Joined: Jan 03, 2001
Posts: 147
Hi Friends,
I am running an applet, but not in a browser instead in a pop-up window. Whenever a user types in a path of the applet , a pop up window opens containing an applet. Browser, however remains active behind the pop up window.
The problem is when I closes the pop up window(i.e., when destroy method of applet is being called) , pop up window gets closed smoothly but the browser than hangs up. What could be the solution, guys ??
Let me know. Need urgent hlp of urs.
Thanx and regards,

Best wishes,
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Sam,
This is probably something in the windowClosing() method that listens for events related to your pop-up window... It may be calling System.exit()... something I have problems with all the time when porting from application to applet... browsers do not like System.exit()... usually it just throws an error, but it may be something related to this... anyway, instead of doing a System.exit() set your pop-up window Frame to setVisible( false )... that will hide your pop-up window and return control to the applet/browser window that launched it.
Your message also alludes to the fact that Applet.destroy() is being called... if your code actually does call Applet.destroy() you should change it... your code should not call it directly, it is used by the JVM in the browser to destroy your applet when the browser exits... if this is the case you should remove the calls to Applet.destroy().
HTH,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Sam Cala
Ranch Hand

Joined: Jan 03, 2001
Posts: 147
You didn't get that. I have a browser working in background and I have an applet working in the pop up window . When i close the pop up window , i.e., the applet, the pop window get closed smoothly but my browser gets hanged. What could be thew reason ?
Regards,
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Sam,
How are you closing your pop-up window?
Could you post some code of this?
-Nate
Sam Cala
Ranch Hand

Joined: Jan 03, 2001
Posts: 147
Hi Friend,
Here it is my code (this is the servlet which is invoking the HTML which integrate the Applet Code) :
public void doGet(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException, IOException
{
PrintWriter printwriter=httpservletresponse.getWriter();
httpservletresponse.setContentType("text/html");
pp=httpservletrequest.getParameter("T1");
b=true;
if (b)
{
printwriter.println("<html>");
printwriter.println("<script language='javascript'>");
printwriter.println("function ");
printwriter.println("doit(htmlfile) { popUpWin=window.open(unescape(htmlfile),'smallWin','height=500,width=700,toolbar=0,location=0,directories=0,status=,menubar=0,scrollbars=,resizable=0')");
printwriter.println("if (navigator.appName=='Netscape') { ");
printwriter.println("popUpWin.focus()");
printwriter.println("}");
printwriter.println("}");
printwriter.println("function heloo() { " );
printwriter.println("javascript: doit('http://vikrant:8080/pop.html?"+URLEncoder.encode(pp)+"')");
printwriter.println("}");
printwriter.println("</script>");
printwriter.println("<tr>");
printwriter.println("<td width='100%'><font face=Arial><Font color=#283d6c> ");
printwriter.println(" There are currently 262 user(s) logged into this ");
printwriter.println(" �</font></font> ");
printwriter.println(" <p> <font face=Arial><Font color=283d6c>Please wait while the client finishes loading. this may take a minute or so");
printwriter.println(" </font></font><br><font face=Arial<font ");
printwriter.println(" color=#283d6c>depending on your computer and connection speeds. Please be patient...�</font></font>");
printwriter.println("Your automatic address could be ");
printwriter.println(" http://vikrant:8080/"+pp);
printwriter.println("<body onload='heloo()'>");
printwriter.println("</body>");
printwriter.println("</html>");
}
}
}
public void init(ServletConfig servletconfig) throws ServletException
{
super.init(servletconfig);
}
}
Look at the code which is invoking pop.html. This is a javascript function which is opening up a pop up window and displaying applet in that window(applet tag is integrated in pop.html) and here is the code of pop.html :
<html>
<body leftmargin=0 topmargin=0 rightmargin=0>
<applet code="socs" width=700 height=500 vspace=0 hspace=0>
</applet>
</body>
</html>

Now, whenever the above servlet is invoked the browser displays a page consisting in a servlet but an applet is opened up in a separate pop up window (as expected through the javascript code in the servlet), now when I try to close the pop up window(i.e., the applet), it gets closed smoothly but browser gets hanged.

Hope now u get it, my dear friend. Do suggest a solution, if possible.
Regards,
[This message has been edited by Sam Cala (edited February 26, 2001).]
[This message has been edited by Sam Cala (edited February 26, 2001).]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Sam,
I don't think the problem is with the applet ( since you said that it was running correctly in the popup window, and the problem only happens after you close it... ). The problem is probably with either your servlet or javascript code... Which I am not sure I know enough of off the top of my head to help you much with... I will look in some JavaScript books and Servlet books when I get home to see if I can find any problems ( I am at work right now and don't have them with me... ). There is also a forum on here specifically on Servlets and another for HTML/JavaScript issues that you may also want to ask on...
When you say that the browser "hangs" exactly what do you mean? Will it let you do anything? Does it crash the computer or the browser? Give an error message? Or just completely lock up with no message, forcing a reboot of the machine or a shutdown of the browser process via the Windows Task Manager?
This may also help find a solution to your problem...
Sorry I couldn't help more...
-Nate
[This message has been edited by Nathan Pruett (edited February 27, 2001).]
Sam Cala
Ranch Hand

Joined: Jan 03, 2001
Posts: 147
Hi Friend,
Browser gets hanged means it get locked and not let me do anything. I just have to restart the computer than.
Anyway, thanks for your suggestions and guidance.
With warm regards,
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need urgent Help - Browser is hanging
 
Similar Threads
Signed Applet Issue - Urgent
applet in a HTML file (URGENT)
prevent "control n" from opening a new browser window with an applet
Disable Right Click on Plugin....Help....Urgent...
applets - urgent !