NullPointerException on getParameter method

C

cold80

I'm trying to get a parameter for my applet from the a web page but I
always receive a NullPointerException. I'm developing with JBuilder,
and debugging the code I can see the line:

this.getParameter("ProxyURL")

thorws this exception. I've tried this line of code in the applet
constructor and the the jbInit method of the applet, but I get always
the same result. I'm sure the name of the parameter is correct, and I
have tried the applet with JBuilder and with a stand-alone web page
too. What can I do?

Many thanks

Cold
 
A

Andrew Thompson

I'm trying to get a parameter for my applet ..

[1] Code?
..from the a web page ..

[2] URL?
..but I
always receive a NullPointerException. I'm developing with JBuilder,

Does it work when you use the command line and a browser?
..and debugging the code I can see the line:

this.getParameter("ProxyURL")

thorws this exception. I've tried this line of code in the applet
constructor and the the jbInit method of the applet,

<pointedly>
What 'jbInit' method?
...but I get always
the same result. I'm sure the name of the parameter is correct, and I
have tried the applet with JBuilder and with a stand-alone web page
too. What can I do?

Supply [1] & [2].
 
T

Thomas Fritsch

cold80 said:
I'm trying to get a parameter for my applet from the a web page but I
always receive a NullPointerException. I'm developing with JBuilder,
and debugging the code I can see the line:

this.getParameter("ProxyURL")

thorws this exception. I've tried this line of code in the applet
constructor and the the jbInit method of the applet, but I get always
the same result. I'm sure the name of the parameter is correct, and I
have tried the applet with JBuilder and with a stand-alone web page
too. What can I do?

Many thanks

Cold
Don't do any applet initialization in the applet constructor, like
calling this.getParameter(...) or jbInit(), because the applet is not
completely initialized then. (To be more precise: the
browser/appletviewer didn't call setStub(...) of your applet yet, and
therefore several applet methods throw a NullPointerException.)

Instead, do these things in the init() method.
BTW: Your JBuilder should have generated the jbInit() call inside the
init() method. Keep it that way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top