I'm trying to find an easy way that, when a user clicks on an SVG-generated image in a browser, the original text that was used to generate that SVG is copied into the user's buffer. The most general solution appears to be the window.prompt() Javascript method, but it requires two additional keystrokes on the part of the user to copy the text and to close the prompt window. Given that
Java applets allow one to copy text into a system's buffer, I was wondering whether AJAX might provide a solution here; that is, upon clicking the image, start a Javascript method that uses AJAX to send the text to a
JSP page that has a Java routine that copies the text into the System buffer. So I wrote such code, but I get a HeadlessException when I try to get the system's Clipboard. Here's the code that throws the exception:
I tried temporarily setting the system's headless property to false, but no joy:
So, my question is, is there any way to salvage this attempt, or am I completely barking up the wrong tree?