Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

Way to capture System.out in a *sandboxed* app.?

Thread view: 
Andrew Thompson - 01 Nov 2007 12:56 GMT
System.out/err cannot be redirected in a sandboxed**
application(/applet).

Assuming you wanted to to show the end user the
System.out/System.err from a *sandboxed* app.*, how
would you go about collecting the information?

* Note - I am looking at launching apps. written by other
people, so I need to intercept/duplicate the normal
System.out/err they might use.  The GUI might be
invoked by a 'full trust' app. - then the task is easy,
*but otherwise,* is there a (sandboxed) way to intercept
those streams?

**This (sandboxed) Applet is not allowed to set the
output stream..

<sscce>
import java.applet.Applet;
import java.awt.Label;
import java.io.PrintStream;
import java.io.ByteArrayOutputStream;

public class RedirectOutputInApplet extends Applet {

 public void init() {
   try {
     PrintStream ps = new PrintStream(
       new ByteArrayOutputStream());
     System.setOut(ps);
   }  catch(Throwable t) {
     add(new Label(t.getMessage())  );
   }
 }
}
</sscce>
Christian - 01 Nov 2007 18:17 GMT
Andrew Thompson schrieb:
> System.out/err cannot be redirected in a sandboxed**
> application(/applet).
[quoted text clipped - 32 lines]
> }
> </sscce>

may be it would do if you run some program in a childprocess you could
redirect the output stream to your likings:

see Process  and ProcessBuilder  classes
Roedy Green - 01 Nov 2007 22:42 GMT
>may be it would do if you run some program in a childprocess you could
>redirect the output stream to your likings:
>
>see Process  and ProcessBuilder  classes

IIRC exec is off limits to unsigned Applets too.

I think he is stuck using something other than System.out.  And
displaying the results in a scrolling JTextArea.
e.g. log.print( String );
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Andrew Thompson - 02 Nov 2007 00:27 GMT
>>may be it would do if you run some program in a childprocess you could
>>redirect the output stream to your likings:
>>
>>see Process  and ProcessBuilder  classes
>
>IIRC exec is off limits to unsigned Applets too.

Correct.  Runtime.exec() and ProcessBuilder.start() both
throw security exceptions in sandboxed apps.

>I think he is stuck using something other than System.out.  And
>displaying the results in a scrolling JTextArea.
>e.g. log.print( String );

Logging is already implemented.  If the child apps.
utilise the logger we provide, we are set.  It was the
'legacy components' that use no logging that I am
more interested in at the moment.

But it seems there is no way.  So I'll 'try' to redirect
the streams, then immediately after that (before the
'catch'), add the 'view output' menu item.

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.