• Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet and java application

 
Suka Hati
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi....
I have a servlet that will call a java application to execute.
Java application will produce an output which is wave file.
If I try to run the java file itself (stand-alone)and if it fails to produced an output an error message will appear at the dos windows.

The problem is how to transform that : System.out.println("error message")
to html ?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you run the external program using java.lang.Runtime.exec, you can access that programs input, error and output streams using the Process object which the exec call returns. That way you can capture the output, and present it to the web user any way you want.
 
Lee Barney
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While you can do this using the runtime exec as described it is highly non-optimal in performance. It is also very bad OO design. You should have an API that allows you to access the functionallity of the application directly from yours if you want to increase performance, reduce used resources, and have the OO design principles that allow for easier upkeep of the code.
 
Rajesh Agarwal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suka Hati,

Thats correct, you should have an API for the other application. Probably a jar or an ear file. You can make calls to that application from yours just the way normal java programming is done. It would be apt for the external application to throw an exception so that you can get to know the error in your servlet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!