• 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Little bit of a problem here: Need URL but don't have it!

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet that does some Java3D stuff. No problems there, but I want that applet to pull files (3D images) over the Internet for use in a CompressedGeometryFile.

That class only has the following constructors:

CompressedGeometryFile(java.io.RandomAccessFile file)
CompressedGeometryFile(java.lang.String file)


Unless an applet is signed, you can't do the RandomAccessFile thing across the Internet I believe. If the constructor would have taken a URL, then everything would be fine, but it doesn't.

So, is there a way around this without getting the applet signed? In other words, can I read a file from my server (using a servlet) and push it back to my applet without the security monitor complaining?

THANKS!
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure... your applet can access your servlet, the your servlet send the drawing over http. In your applet, you get the response, read the data byte by byte in a array[] then you do what ever you want with it. What you describe is the normal way to do that:

http://mindy.cs.bham.ac.uk/AppletServletExample/
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Alain Boucher:
Sure... your applet can access your servlet, the your servlet send the drawing over http. In your applet, you get the response, read the data byte by byte in a array[] then you do what ever you want with it. What you describe is the normal way to do that:

http://mindy.cs.bham.ac.uk/AppletServletExample/



Thanks for the reply, and although I understand this (use servlets to send back things all the time) I'm not getting it for this instance.

The thing is, I need to end up with something on the applet side that the CompressedGeometryFile will accept. All it takes is a RandomAccessFile.

Unless there is some way to convert an InputStream into a RandomAccessFile maybe, I'm still out of luck. If there is, it isn't obvious to me (I really don't like Java io much BTW).

Thanks.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could read the data yourself and use the CompressedGeometry class directly.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just write the stream to a temp RandomAccessFile...



Probably not the most efficient, but it works.

[Ed. Changed main() to a more exciting demo]
[ May 18, 2005: Message edited by: Erik Larson ]
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much for the suggestion, but this has the same sort of problem...a security error.

When I try to run this, I get an exception on this line:
RandomAccessFile raf = new RandomAccessFile(File.createTempFile("isc", "tmp"), "rwd");

The exception is "Unable to create temporary file".

I do appreciate the help though.


Originally posted by Erik Larson:
Just write the stream to a temp RandomAccessFile...



Probably not the most efficient, but it works.

[Ed. Changed main() to a more exciting demo]

[ May 18, 2005: Message edited by: Erik Larson ]

 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:
You could read the data yourself and use the CompressedGeometry class directly.



I tried this but it died during the decompression process. I think the problem might be that you need to fill out the CompressedGeometryHeader class with details about the file you are loading, and I was just passing in a anonymous CompressedGeometryHeader. This is just a guess though.

I think I might have to end up signing the applet when it is all said and done.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ugh, sorry. This is a really bad design flaw.
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:
Ugh, sorry. This is a really bad design flaw.



Yes, it is.

There was a defect submitted years ago, but then Sun drug its heels and then opensourced Java3D and the defect never was resolved. All they needed to do is give the file version a construction that takes a URL, but...
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I did this, jarred up the applet, and got it signed (to get around the security problem of the temporary file) and tried it out.

It works, but it is slower than molasis on a cold winters day!

I mean s-l-o-w as in taking 10 minutes or more to read less than one meg across ethernet.

I tried adding a 2K buffer to the read, but that didn't help.

Thanks for trying though!






Probably not the most efficient, but it works.

[Ed. Changed main() to a more exciting demo]

[ May 18, 2005: Message edited by: Erik Larson ][/qb]<hr></blockquote>
[ May 20, 2005: Message edited by: Darrin Smith ]
 
    Bookmark Topic Watch Topic
  • New Topic