• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Executing programs

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgive my inexperience, but given an input from a client, can a servlet take that input and execute a program residing on the server-side? Just for an example, a webpage comes up with a button that says "Click to run Servletrunner" and the user clicks on it and the /usr/local/jsdk/bin/servletrunner daemon is started through the servlet somehow.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't imagine why you would do that particular example, but yes, a servlet can essentially do anything a freestanding application can do. Most servlets books, including mine, have examples.
You have to use one of the java.lang.Runtime exec methods, get a process, and handle the input and output streams from the process. Kind of hard to debug from the servlet so I recommend you put the process in a helper object and test it stand-alone first.
Bill
------------------
author of:
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!