• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

applet works from command line but not in browser...

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I thought Id cross post this to the applet page, even though i already posted it to the jdbc page.
Im pretty new at java, and im trying to create an applet that connects to a database on a remote machine. So far, I have been able to connect to the database if i invoke the appletviewer from the command line like this:
C:\java>appletviewer -J-Djava.security.policy=DbaApplPol.txt protocols.html
where protocols.html has the code:
APPLET CODE=JdbcApplet2 codebase="." archive="classes111.zip" width="400" height="175"

and JdbcApplet2 is the applet code that connects to the database. I found out that to envoke the applet from the command line, i had to have a file in the same directory called DbaApplPol.txt that has the following lines in it:
grant {
permission java.net.SocketPermission "developer", "resolve";
permission java.net.SocketPermission
"", "connect,resolve";
grant {
permission java.lang.RuntimePermission
permission java.util.PropertyPermission
"file.encoding", "read";
to grant the applet permission to access the database. This combination of JdbcApplet2 code, DbaApplPol.txt, and invoking the applet from the command line works, and does exactly what it is supposed to do. however, when i load up the web page by itself (not from the command line, just double-click on the icon from my C:\java\protocols.html), the applet does not work. I believe it is because the applet when loaded in the web page cant utilize the DbaApplPol.txt permissions file. So if this is the case, how can I get the browser to recognize the permissions set up in the DbaApplPol.txt file? Or is there some other way people do this? Is there any way to do this without having to change the browser options?
Saloon Keeper
Posts: 22127
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd have to sign the applet. Also if there's a firewall blocking access to port 1521 between the browser and the webserver (and there often is), you're doomed.
Greg Buron
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for the reply. I am actually working behind a firewall, and the web page would only be for people behind the firewall as well (an intranet page). I guess i dont really need to use applets, just something ive never done before and was wondering if it would be easier than creating a static page. I think it would be easier all around if i just create a servlet to make those pages.
Anyway, thanks for your speedy reply, that was helpful!
Catch Ernie! Catch the egg! And catch this tiny ad too:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic