0

I am experiencing a little problem reading parameters from an html page to an applet.

my code (necesssary for question):

on html page:

<PARAM NAME = "name" VALUE = "Nicholus">

in applet (init):

String strName = getParameter("name");

The applet just decides to look at me instead of getting the name value.. a few google search shows im not the only one, except I haddn't yet found the solution, so I decided to post it here in case it was already resolved.

Naveen
  • 7,944
  • 12
  • 78
  • 165
Javanova
  • 1
  • 2

2 Answers2

0

Compare your work with the following working code or post your code if problem still not solved.

Here is the ParamDemo.java code

 import java.awt.*;
import java.applet.*;

public class ParamDemo extends Applet{
    String strName;
    public void start()
    {
        strName=getParameter("name");
        if(strName==null)
            strName="Not Found";
    }
    public void paint(Graphics g)
    {
        g.drawString("Name :"+strName,10,20);
    }
}

Then the Applet.html

<html>
<body>
<applet code="ParamDemo" width="300" height="300">
<param name='name' value="Nicholas">
</applet>
</body>
</html>

Snapshot enter image description here

[Ps:You need to compile your .java before using in HTML page and make sure that there is no problem related to leter-case of parameter-names as java is case-sensitive.Also the .class and .html files must be in same root folder).

Naveen
  • 7,944
  • 12
  • 78
  • 165
0

I got it solved, my negligence... my html had many applet codes, the params were not printed within the applet declaration of the one that needs the params. thanks for contributing.

Javanova
  • 1
  • 2