If you search Google for Firefox JavaScript copy clipboard you will see how to do it. Problem is security settings. most browsers have this disabled by default.
Or else could i ask you that, is there any other approch to do this?I mean using java? Usually what developers will do if this requirement arrives...!?
Java is running on the server and has no connection to the client. You can try to worrk with an applet, but that also has issues with support on the browser.