aspose file tools*
The moose likes Applets and the fly likes Applet HTML question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet HTML question" Watch "Applet HTML question" New topic
Author

Applet HTML question

Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 687
    
    1
Hi,

I'd want to have the HTTP GETs from a browser go thru a cgi script both for the HTML and the java classes.
How do I code that?

This HTML will send the browser to the cgi for the HTML:
<A href="cgi-bin/GetAFile.pl?Testing\AppletLoader.html">
This is the HTTP GET created by the above:
GET /cgi-bin/GetAFile.pl?Testing\AppletLoader.html HTTP/1.1


Now I'd like the browser to issue this GET:
GET /cgi-bin/GetAFile.pl?Testing/AppletLoader.class HTTP/1.1

How do I code the HTML to cause the browser to issue this GET?

My attempts at using the code= and codebase= have failed:

//This one failed html=codebase="GetAFile.pl%3f"
GET /cgi-bin/GetAFile.pl%3f/AppletLoader.class HTTP/1.1 <<< Close?

//This one failed html=codebase="GetAFile.pl?" how to send a ?
Browser does two gets:
First: GET /cgi-bin/AppletLoader.class HTTP/1.1
Second: GET /cgi-bin/AppletLoader/class.class HTTP/1.1


//Failed html=<APPLET CODE="cgi-bin/GetAFile.pl?AppletLoader.class"
GET /cgi-bin/cgi-bin/GetAFile/pl?AppletLoader.class HTTP/1.1
Note: .pl changed to /pl???

// Failed html=codebase="GetAFile.pl?"
GET /cgi-bin/AppletLoader.class HTTP/1.1

//Almost?? html=codebase="GetAFile.pl%3FTesting/" <<< should %3f Be decoded by server??
GET /cgi-bin/GetAFile.pl%3FTesting/AppletLoader.class HTTP/1.1


I've been testing on my own server and perhaps it should decode the %3F in the last example.

Thanks,
Norm
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
I'm not quite clear on what you're trying to achieve. Do you actually want to run the applet? Or just download the class file? To run the applet, not the browser but the JVM would need to download the class file. How that happens is governed by the URLClassLoader class, so a look at the source of that might help. URLClassLoader may make use of the networking capabilities of the browser, but I doubt that it understands parameters.
Maybe if you map URLs on the server, you could make URLs that trigger CGIs look like regular directory/file URLs, and thus fool the JVM into accessing dynamic content for its class files.


Ping & DNS - my free Android networking tools app
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 687
    
    1
Ulf,
Thanks for the response. I see you're working today.
I'm trying to write a poor man's applet code protector using a perl script.

> To run the applet, not the browser but the JVM would need to download the class file
The HTTP GETs I posted for the class file were cause by the following java statement:
Class appletClass = Class.forName(appletToLoad);

>URLClassLoader may make use of the networking capabilities of the browser, but I doubt that it understands parameters.

Somewhere in the JVM, it issues an HTTP GET for the class file. I've captured the GET statements I posted as they hit the server.
I've tried various combinations and have some that are close, but not exactly correct.

Since my server is homegrown, I wonder if when it receives:
GET /cgi-bin/GetAFile.pl%3FTesting/AppletLoader.class HTTP/1.1
should it decode the %3F to a ? before stripping off the query string?
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 687
    
    1
codebase="GetAFile2.pl/Testing"
This value for the applet attribute seems to work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet HTML question