-
April 10th, 2001, 09:38 AM
#1
Applet needs to warn a servlet
I need my applet warns a servlet that it is finilizing, from stop() method (for instance). I am doing an url call, into my applet stop method, like:
try
{
URL StopConnection = new URL(getCodeBase()+"/myServlet");
try
{
URLConnection sc = StopConnection.openConnection();
} catch (IOException e)
{
System.out.println("Exception ending applet " + e);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
It does not work, maybe there is something wrong or it is impossible to do what i need to. If someone has an idea, please, i will apreciate it!
Maribel
-
April 11th, 2001, 09:58 AM
#2
Re: Applet needs to warn a servlet
How does it fail? Does the connection fail? does it throw an exception? How does the servlet know it is a finalize warning? Does the servlet get the message?
If it's a problem with the connection, here's a reliable way of making one:URL currentPage = getCodeBase();
String protocol= currentPage.getProtocol();
String host = currentPage.getHost();
int port = currentPage.getPort();
String urlSuffix = "/servlet/MyServlet";
URL dataURL = new URL(protocol, host, port, urlSuffix);
URLConnection connection = dataUrl.openConnection();
...
Dave
To email me remove '_spamjam' from my email address
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
April 11th, 2001, 05:02 PM
#3
Re: Applet needs to warn a servlet
I tried some experiments with an applet's stop() method using code that worked in the init() method. I used both IE5.5 and Netscape 4.? No messages were sent to my localhost server from the stop() method. So is my code bad or does the browser NOT allow communication from the stop() method?
Norm
Norm
-
April 12th, 2001, 09:43 AM
#4
Re: Applet needs to warn a servlet
I changed my code and was able to send a message to the server from the applet's stop() method using a Socket. Forget the other message
Norm
Norm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|