This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes Applet introspection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet introspection" Watch "Applet introspection" New topic
Author

Applet introspection

Angus Rose
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Is it possible to load an applet into an application and use the reflection api in order to see what methods and attributes the applet conatins?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Yes.


[Jess in Action][AskingGoodQuestions]
Angus Rose
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Well thanks for the short and sweet reply. The next question is how?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

An applet is no different from any other object. You get the Class object for the applet class, then use the getDeclaredMethods() and getDeclaredFields() methods to investigate it.
Angus Rose
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Can it be done on an applet that is currently running in a browser?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Sure, by code in the applet itself, or by another applet on the same page if the target applet has the MAYSCRIPT="TRUE" attribute on the HTML page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet introspection
 
Similar Threads
Java program protection.
Clock
Clock
WA #1.....word association
Applet with a ServerSocket