Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using java.awt.Robot from a Servlet?

Status
Not open for further replies.

mluken

Programmer
Dec 31, 2003
54
US
I need to have a servlet that will do a Print Screen of the server machine. Here is the code that I am using:

import java.awt.*;
//----------
int printScreenKey = KeyEvent.VK_PRINTSCREEN;
RobotInterface r = new RobotInterface();
r.keyPress(printScreenKey);

If I run this from a DOS prompt from the server, it does a Print Screen. However when I run it from a servlet, it does not. Any ideas why???

Thanks!
 
A servlet doesn't have any specific console "assigned" to it. The System.out doesn't go to a window, it goes to the server program (ie: Tomcat) which then decides whether to echo it to a window or to a log or something.

So there's no device to get a screen print from.
 
Hmmm so basically what you are saying is that there is no way that I can do what I am trying to accomplish?
 
Well, if the server is physically under your control (ie: you can run programs on it other than the application server itself), you could load your program on the console and have it wait, listening on a socket.

In your servlet, you could open a socket connection to the app and signal it to take a screen shot and return it to you via the same socket connection.

The concole app could be loaded up automatically during reboots in various ways, depending on the version of Windows you use. You could not run it as an NT Service, however, because it would have the same problem as the servlet version.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top