Introduction to AWT and Applets · Introduction to Java Programming

Applet Parameters

Watch lectures

Applet Parameters

1. What Are Parameters? (beginner)

Params = settings from HTML to applet (no recompile to change name/color!). Like function args, but from web page! <param name="msg" value="hi"> → getParameter("msg") → "hi"!

2. Code — HTML + Java (exam pair!)

<!-- page.html -->
<applet code="Hi.class" width="300" height="100">
  <param name="msg" value="Hello Web!">
  <param name="size" value="20">
</applet>

3. Rules (traps!)

  • ALL params are String (parse numbers yourself!).
  • Missing → null (check! else NPE!).
  • getParameter in init() (once! not paint!).

4. Modern Twin (viva!)

Applets dead, but SAME idea lives: command args (args[]), properties (-Dmsg=hi), env vars, config files!

5. Exam Points

  • HTML + getParameter program — 5-7 marks, frequent.
  • String-only + null-check — 3 marks, frequent.
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Introduction to Java Programming modules