Applet -- Getting a list of parameters?

H

Hal Vaughan

I'm working on a small JApplet class that is a wrapper class. It will call
the main class, which can also be run on a system as an application. I'll
be using this JApplet class in different contexts, so I'd like it to get a
list of the parameters passed to it from the web page. All I can find is
the getParemeter() method. I can't find anything that will let me get a
list of all the parameters. Is there a way to do that?

I figured I could get a list of parameter names and use that to get each
parameter value, then pass them on to the primary class file as a String[]
object. That way the primary class for this and future applets can all be
called from a main() function in the application class and from a JApplet
class as well.

Thanks!

Hal
 
H

Hal Vaughan

So should I take it that there is no way to get a list of all the parameters
passed to an Applet from an HTML page?

Hal
 
M

Matt Humphrey

Hal Vaughan said:
So should I take it that there is no way to get a list of all the
parameters
passed to an Applet from an HTML page?

Sadly, that's the truth. If you notice the getParameterInfo method of
applets, they're supposed to publish what their parameters are, not accept
arbitrary lists of parameters. You can circumvent this by using numbered
parameters (param-1, param-2, param-3) and looping through the numbers, but
the end result is still the same--the invoking page must really know what
the parameters are in advance.

http://java.sun.com/developer/JDCTechTips/2001/tt0821.html

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/
 
A

Andrew Thompson

Hal said:
I'm working on a small JApplet class that is a wrapper class. It will call
the main class, which can also be run on a system as an application. I'll
be using this JApplet class in different contexts, so I'd like it to get a
list of the parameters passed to it from the web page. All I can find is
the getParemeter() method. I can't find anything that will let me get a
list of all the parameters. Is there a way to do that?

Parse the HTML itself (is one way*) E.G.
<http://groups.google.com/group/comp.lang.java.help/msg/f1108c5e5b7c883f>

( * the one way I am 'prepared to share', in any case.. ;)

Andrew T.
 
H

Hal Vaughan

Matt said:
Sadly, that's the truth. If you notice the getParameterInfo method of
applets, they're supposed to publish what their parameters are, not accept
arbitrary lists of parameters. You can circumvent this by using numbered
parameters (param-1, param-2, param-3) and looping through the numbers,
but the end result is still the same--the invoking page must really know
what the parameters are in advance.

http://java.sun.com/developer/JDCTechTips/2001/tt0821.html

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/

That's about what I had figured. I understand the idea that one should know
the parameters for what is being called and an applet should specify the
needed parameters. In this case, the applet class itself is a wrapper for
other applets, so I'd like to make that class as generic as possible.

I'm not trying to knock Java, but this is the kind of thing I often find
frustrating in Java: Do it our way or not at all. Some languages go out of
their way to let you find ways to do what you want and it seems that Java
is more concerned with drawing lines and saying, "You can't go outside
here." There's a lot of things I like about Java, but finding roadblocks
like this is not one of them.

Thanks for the info.

Hal
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top