my dog learned polymorphism*
The moose likes Applets and the fly likes Getting parameters from the htmp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Getting parameters from the htmp page" Watch "Getting parameters from the htmp page" New topic

Getting parameters from the htmp page

Sameera Abeysinghe
Ranch Hand

Joined: Nov 15, 2004
Posts: 104
This is my html page
<APPLET codebase="file:C:/Documents and Settings/ok4/Desktop/Test/" code="Slideold11.class" width=250 height=300>
<param name="Color" value="blue">

This is my java code
System.out.println("done ");
String paths=new java.applet.Applet().getParameter("Color");//

This is my error
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at java.applet.Applet.getParameter(Unknown Source)
at Slideold11.getImage(
at Slideold11.paint(
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at Source)

Any one that can tell me what�s my problem and a the answer for this
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41147
Assuming that the Java code is part of the applet, you need to write

String paths = getParameter("Color");

The Applet object is created for you by the browser; it's wrong to create one yourself.

Ping & DNS - my free Android networking tools app
wood burning stoves
subject: Getting parameters from the htmp page
Similar Threads
file reading in applet
Applet not getting initialized
WAMP/Java/MysqlConnector Issue
Exception while loading applet
applet security error online