Article ID: 168942
Article Last Modified on 11/14/2005
import java.io.*;
import java.net.*;
import java.applet.*;
import java.awt.*;
class ReadFile extends Applet {
public void start () {
try {
URL u2 = new URL(getCodeBase(),"poem.txt");
DataInputStream d = new DataInputStream(u2.openStream());
String s5 = d.readLine();
add(new Label(s5));
}
catch (Exception e) {
System.out.println("Error: " + e.toString());
}
}
}
public int getCurrentImage() {
return m_nCurrImage;
}
<form action="/scripts/info.dll" method=GET name="myForm" >
<applet code=AppletInForm.class id=myapplet
width=320 height=240 >
</applet>
<input type=hidden name="appletImage">
<script language=JScript>
function processApplet() {
parent.myForm.appletImage.value=document.myForm.myapplet.getCurrentImage();
alert("Sending form: image="+parent.myForm.appletImage.value+"
user="+parent.myForm.Username.value);
}
</script>
<br>
Username:<input type=text name="Username"><br>
<input type=submit value="Please send me the above picture."
language="JScript" onClick="processApplet();">
</form>
.\sun\net\www\protocol\ftp
.\sun\net\www\protocol\ftp\Handler.java.
package sun.net.www.protocol.FTP;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
public class Handler extends URLStreamHandler {
public synchronized URLConnection openConnection(URL u) {
return new FTPURLConnection(u);
}
}
package sun.net.www.protocol.FTP;
import java.io.IOException;
public class FTPURLConnection extends sun.net.www.URLConnection {
FTPURLConnection(java.net.URL u) {
super(u);
}
public void connect() throws IOException {
throw new IOException("FTP doesn't support connect().");
}
}
import java.net.*;
public class FTPTest extends java.applet.Applet {
public void init() {
add(new java.awt.Button("Click to open FTP session."));
}
public boolean action(java.awt.Event evt, Object what) {
try {
URL u=new URL("ftp://ftp.microsoft.com");
getAppletContext().showDocument(u,"FTPFrame");
} catch (Exception e) {
showStatus(e.toString());
e.printStackTrace();
}
return true;
}
}
jview main > javalog.txtThis works for both jview and wjview. Or, you could programmatically direct the output to a file or pipe by reassigning System.out. The following code, which works for jview/wjview and Internet Explorer, shows how this can be done:
if
("true".equalsIgnoreCase(System.getProperty("com.ms.applet.enable.logging")
)) {
try {
String logdir = System.getProperty("java.home");
PrintStream ps = new PrintStream(new BufferedOutputStream(new
FileOutputStream(new File(logdir,
"javalog.txt"))), true);
System.out = ps; // comment line if using SDK 2.0x
// System.setOut(ps); // uncomment line if using SDK 2.0x
System.err = ps; // comment line if using SDK 2.0x
// System.setErr(ps); // uncomment line if using SDK 2.0x
} catch (Exception e) {
}
}
The ability to alter the value of System.out and other system streams may
be removed or changed in the future.The problem is that Applets aren't ActiveX containers and therefore cannot host ActiveX controls. The call to "new myActiveXControl();" doesn't make sense because there is no container to host the control. You should use an <OBJECT> tag in your HTML file, and then pass this object reference to your Applet. For an example of how this is done, see the "OLEControls" sample in the Microsoft Visual J++ samples documentation.
You need to use the AXComponent class, located in the com.ms.activeX package, to host your ActiveX control.
String build;
build=SystemVersionManager.getVMVersion().getProperty("BuildIncrement");
System.out.println("Using build "+build);
HKEY_Current_User\Software\Microsoft\Java VM\EnableJIT
Keywords: kberrmsg kbinfo kbjit kbdatabase kbcommandline kbfaq KB168942