NEED JAVA EXPERTS HELP : How to do these ?????

NEED JAVA EXPERTS HELP : How to do these ?????

Post by Eric, Chow Hoi K » Wed, 01 Jul 1998 04:00:00



Hello,
How can I output the following this in homepage ????

import java.applet.Applet;
import java.io.*;

public class test extends Applet {
 public void init() {
  println("Content-type: text/html");
  println("<HTML>\n");
  println("<BODY>\n");
  println("Hello World\n");
  println("</BODY>");
  println("</HTML>");
 }

Quote:}

I know that it is impossible to output "Hello World" to a certain
homepage with the above codes. So, could you pleased to tell me how can
I do this ? And could you pleased to give me a simple example ??

Best regards,
Eric

--

     _  |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|  _
    / ) |     Eric, Chow Hoi Ka            ICQ# : 3463514     | ( \
   / /  |                                                     |  \ \
 _( /_  | _   ICQ-Page : http://wwp.mirabilis.com/3463514   _ |  _) )_
(((\ \> |/ )                                               ( \| </ /)))

 \       /                                                   \        /
  \    _/     http://www.sftw.umac.mo/~d951686/               \_     /
  /   / |_____________________________________________________| \    \
 /   /                                                           \    \

 
 
 

NEED JAVA EXPERTS HELP : How to do these ?????

Post by Cheng Jiun Yua » Wed, 01 Jul 1998 04:00:00



Quote:> Hello,
> How can I output the following this in homepage ????

> import java.applet.Applet;
> import java.io.*;

> public class test extends Applet {
>  public void init() {
>   println("Content-type: text/html");
>   println("<HTML>\n");
>   println("<BODY>\n");
>   println("Hello World\n");
>   println("</BODY>");
>   println("</HTML>");
>  }
> }

> I know that it is impossible to output "Hello World" to a certain
> homepage with the above codes. So, could you pleased to tell me how can
> I do this ? And could you pleased to give me a simple example ??

I assume u want to create a HTML document on the fly from your applet and
then show it to
the browser.

I don't have any simple example. But u can check out the Live Connect from
Netscape Developer Homepage
developer.netscape.com for some examples. Live Connect allows u to call
JavaScript methods from Java Applet.
With JavaScript, u can show HTML content on the fly.

Alternatively, u can try this:

String str = "javascript:\"<HTML><BODY>Hello World</BODY></HTML>\"";
try {
  URL url = new URL(str);
  getAppletContext().showDocument(url);

Quote:} catch (MalformedURLException e) {

  e.printStackTrace();

Quote:}

I don't know if the 'javascript' protocol is supported by the java.net
package.

For complicated HTML content, Live Connect is a better solution.