Executing Programs
Sometimes a servlet needs to execute an
external program. This is
generally important in situations where an external program offers
functionality that isn’t easily available from within Java. For
example, a servlet could call an external program to perform an image
manipulation or to check the status of the server. Launching an
external program raises a number of security concerns. For this
reason, it’s an action that can be taken only by servlets
running with a fairly lenient security manager—specifically, a
security manager that grants permission for the servlet to call the
exec()
method of java.lang.Runtime
.
Finger
The
finger program queries a (possibly remote)
computer for a list of currently logged in users. It’s
available on virtually all Unix systems and some Windows NT machines
with networking capabilities. The finger program
works by connecting to a finger daemon (usually named
fingerd
) that listens on port 79.
finger makes its request of
fingerd using a custom “finger”
protocol, and fingerd replies with the
appropriate information. Most Unix systems run
fingerd, though many security-conscious
administrators turn it off to limit information that could be used
for break-in attempts. It’s still fairly rare to find
fingerd on Windows systems. Run without any
arguments, finger reports all users of the local
machine. The local machine must be running
fingerd. Here’s an example:
% finger
Login Name TTY Idle When Office jhunter Jason Hunter q0 3:13 Thu ...
Get Java Servlet Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.