Protect applets from "stealing" tips (Source: HANIC)

xiaoxiao2021-03-06  114

Protect Applet from "stealing" tips

source

http://blog.9cbs.net/hanic/archive/2004/08/19/78750.aspx

We know that the JavaApplets in the web page are not available from the image files directly from the visitor, but may still be found from the cache, put them on their own web. Therefore, if you want to protect your own applet from "stealing", one of the methods is to let the applet run only in the specified URL page. In the Java language, the URL of the Applet is located in the Java.applet package, can be obtained from getDocumenbase () to get.

For example, in the following program, the applet will first detect the current URL in the initialization phase. Once the setting does not match, the warning message is output in the JavaConsole, and then the operation is automatically suspended, thereby implementing the "copyright protection" of the applet. .

Import java.net. *; import java.applet. *;

Public class myonly extends applet {

Public void init () {string = getDocumentbase (). gethost (); if (! @XXX.com ")) {system.out.println (" Warning! A stolen applet. "); System.exit (1);} else {...}}}

转载请注明原文地址:https://www.9cbs.com/read-125523.html

New Post(0)