[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: how can I open netcdf file in applet?



Dear Monica,

 

I’m not absolutely sure, but I think the problem lies with the security model of Java applets.  I don’t think you’re allowed to load any data from a remote server, except for the server that is hosting the applet itself.  Try loading a netCDF file from your web server – it will probably work.

 

Regards,

Jon

 

--------------------------------------------------------------
Dr Jon Blower              Tel: +44 118 378 5213 (direct line)
Technical Director         Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre   Fax: +44 118 378 6413
ESSC                       Email: address@hidden
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
--------------------------------------------------------------


From: address@hidden [mailto:address@hidden] On Behalf Of ???
Sent: 09 February 2006 07:12
To: address@hidden
Subject: Fw: how can I open netcdf file in applet?

 

Dear All :

   Sorry, I forget add the srouce code and html file.

   Hope it will be help to resolve bugs...

   Thank you.

                                                                        Monica

 

----- Original Message -----

From: 劉育帆

Sent: Thursday, February 09, 2006 3:05 PM

Subject: how can I open netcdf file in applet?

 

Dear All:
  I meet some problem and try two ways to resolve it,

  but still can't resolve.

  I hope someone can give me the correct resolve ways....


  Target :

  I want use Applet and NetCDF Java Library (Version 2) to do
      1. open the remote netcdf file(
http://61.60.103.48:81/g2var1level.nc, the remote file also in same folder with applet class.)
      2. print size and data of the Variable("lon" & "lat") which in netcdf file.


  I can't get the correct result, but get some error message in Java console :

 

  First  way :

  I use the function in Applet to open the remote file,
  (the function can run in application): 


      String urlfile = "
http://61.60.103.48:81/g2var1level.nc";
      NetcdfFile ncfile = NetcdfFile.open(urlfile);

 

  and HTML code use :


      <applet code="MyNetcdfApplet.class" archive="nc2.2.jar" codebase=. width=300 height=400>

      <param name="NCFile" value="http://61.60.103.48:81/g2var1level.nc">
      ...
      </applet>

 

  First way Error message :

   IE version 6.0.2900.2180.xpsp_sp2_gdr.050301-1519
  Java Plug-in 1.5.0_06
  JRE version 1.5.0_06 Java HotSpot(TM) Client VM

 

   java.security.AccessControlException: access denied (java.io.FilePermission http:\61.60.103.48:81\g2var1level.nc read)
  at java.security.AccessControlContext.checkPermission(Unknown Source)
  at java.security.AccessController.checkPermission(Unknown Source)
  at java.lang.SecurityManager.checkPermission(Unknown Source)
  at java.lang.SecurityManager.checkRead(Unknown Source)
  at java.io.File.exists(Unknown Source)
  at ucar.nc2.N3iosp.open(N3iosp.java:93)
  at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:780)
  at ucar.nc2.NetcdfFile.open(NetcdfFile.java:339)
  at ucar.nc2.NetcdfFile.open(NetcdfFile.java:221)
  at ucar.nc2.NetcdfFile.open(NetcdfFile.java:167)
  at ucar.nc2.NetcdfFile.open(NetcdfFile.java:151)
  at MyNetcdfApplet.init(MyNetcdfApplet.java:29)
  at sun.applet.AppletPanel.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)
     

   Second  way :

   I change my code in Applet to open the remote file,

 

       String urlfile = getParameter("NCFile");            
       URL url = "" URL(getCodeBase(), urlfile);

       NetcdfFile ncfile = new NetcdfFile(url);

 

  and HTML code use :


      <applet code="MyNetcdfApplet.class" archive="nc2.2.jar" codebase=. width=300 height=400>

      <param name="NCFile" value="/g2var1level.nc">
      ...
      </applet>

 

 Second way Error message :

 URL http://61.60.103.48:81/g2var1level.nc
 java.security.AccessControlException: access denied (java.io.FilePermission http:\61.60.103.48:81\g2var1level.nc read)
 at java.security.AccessControlContext.checkPermission(Unknown Source)
 at java.security.AccessController.checkPermission(Unknown Source)
 at java.lang.SecurityManager.checkPermission(Unknown Source)
 at java.lang.SecurityManager.checkRead(Unknown Source)
 at java.io.File.exists(Unknown Source)
 at ucar.nc2.N3iosp.open(N3iosp.java:93)
 at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:763)
 at MyNetcdfApplet.init(MyNetcdfApplet.java:33)
 at sun.applet.AppletPanel.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)

 

And I didn't sign My applet. Could anyone tell me what keypoint  I miss?

(May I need sign it? or not add some import jar file?)

 

How can I do that My applet can read the remote netcdf file?
The netcdf file also be in My applet class folder.

First way or Second way is better?

 

Thank you very much~

 

                                                                                    Monica