Parameter File Not Html Params

I wasn't sure this one was an idiom until I was recently leafing through the Gamelan (http://www.gamelan.com) discussion pages and found the same question answered THREE times.

The problem is this. Java has a facility by which you may read a few parameters from the HTML that starts an applet to customize that applet. The problem with this is that that means if you want to change the applet's parameters, you're changing the HTML all of the time. This is especially a problem if you use the same applet in multiple places.

The solution to this is not to use the applet parameters, but instead to have a special, global file of parameters for your applet that's not ordinarily reachable from any of the rest of the HTML. Use a URLConnection to get the contents of the file and then process it with a stream.

-- KyleBrown


Using a URLConnection and a Properties file can avoid HTML params and also make your applet more 'portable' to application type usage...

   URLConnection url = new URLConnection("http://foo.bar/MyApp.props");
   Properties props = new Properties();
   props.load( url.getInputStream() );

String param1 = props.getProperty("parametername"); // etc.

-- StephenPetschulat
EditText of this page (last edited November 3, 2003)
FindPage by browsing or searching

This page mirrored in JavaIdioms as of April 29, 2006