This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Should this Java method run on the server or on the client? If the former, AJAX is -as Bear mentioned- your best bet. If the latter, you could embed an applet in the page that runs the method for you. That'd be a hack, though, with a number of drawbacks.