javaapplet

How does java recognize commented applet html tag in applets program?


I used to java programs in notepad(normal text editor),Usually /*test/* would be counted as comments in a program which won't be interpreted by compiler,

For e.g

import java.io.*;

import java.sql.*;

class products

{

public static void main(String args[])

/*test /*

Here test would be considered as comments
}

But in applets how does /* recognize it in applet viewer and generate the window based on the size and code?

/*<applet code="myaddapplet.java" width="300" height="300">
</applet>
*/

how does not java take it as programming content instead of taking it as comments ?


Solution

  • how does not java take it as programming content instead of taking it as comments ?

    The Java compiler does not read that file.

    It is an HTML file ... or something that generates one (e.g. a JSP). The HTML is read on the client side by your web browser's HTML parser, not by a Java compiler. In fact, it is likely that the user's machine doesn't even have a Java compiler installed.

    The HTML parser does not recognize the /* ... */ as a comment. Depending on where it is, it may treat those characters as literal characters and attempt to show them to the user.

    The <applet>...</applet> part is valid HTML ... which the HTML parser recognizes, and treats as an instruction to launch an applet.