tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Viehl Clemens <>
Subject RE: OT: java programming Q
Date Wed, 10 May 2000 15:44:34 GMT
> The only thing I'm still wondering about is how I can for example
> make the C program sending it's stdout to
> PrintWriter out = response.getWriter(); , in other words, can 
> I write a
> C program cprog or bourne shell script:
> main() { printf("<HTML>Hello World</HTML>"};
> and exec this C program from within the servlet
> String action="cprog";
> Runtime runner= Runtime.getRuntime();
> runner.exec(action);
> This doesn't seem to work. And I havn't yet found where the output 
> goes at all.

runner.exec returns a process.

  Runtime runtime = Runtime.getRuntime ();
  Process process = runtime.exec (action);

  InputStream in  = process.getInputStream ();
  InputStream err = process.getErrorStream ();

This should work.

> > > But for efficiency reasons there's a lot I'd still prefer 
> > > to be done with CGI
> > > programs (C programs).

But i believe you will get a really bad performance using CGI within
Servlets are the replacement for such things and are more performant because
don't need to create a Operating System process as you have with CGIs. But
i'm not sure about this, because i know only servlets. But they are Java
Threads who are present prompt after their first initialization. 
Java isn't too slow when you don't have a gui. Try a fast JVM, that would
improve speed more than mixing C and Java.
Just my 2 cent.


Clemens Viehl

View raw message