Hello,
I have a bunch of servlets already written. Now I have to use them with new
flash pages. I am using Flash Remoting with Flash MX 2004 and Jrun4. I was able
to invoke the servlet from the Flash. But how can I pass the parameters, the
servlet is expecting. For example I have a Logon.java servlet . It is expecting
two parameters 'userid' and 'password' in the HttpServletRequest. The action
script I am using is as follows:
#include "NetServices.as"
NetServices.setDefaultGatewayUrl("http://localhost:8101/flashservices/gateway");
gatewayConnection = NetServices.createGatewayConnection();
servletService = gatewayConnection.getService("compass", this);
function logon_Result(result)
{
_root.output.text = result;
}
function logon_Status( error )
{
_root.output.text = error;
}
In the login button actions I have placed the following code.
on(click) {
_root.servletService.logon();
}
It is invoking the logon servlet on the server. but I have to pass the
parameters and handle the results which it returns.
Thanks & Regards.
glpete - 25 Feb 2004 16:23 GMT
You invoke your servlet like any other remoting object:
servletService.ServletNameGoesHere( userID, password );
Except you use your servlet's name as the method name.
On the server side, your servlet's service method is invoked. You extract the
FLASH.PARAMs attribute:
List params = (List)request.getAttribute("FLASH.PARAMS");
Your userid should be the first parameter (params[0]) and the password the
second (params[1]).
There may be other ways to do this, but this way is working for me.
UTD - 01 Mar 2004 16:34 GMT
Thanks for the solution. But the main thing here is we have to change the
servlet to read the parameters. I don't have any authorisation on changing the
servlet. Is there any way that I can reuse the servlets as it is?
Thanks & Regards.
glpete - 01 Mar 2004 16:45 GMT
Can you introduce a new servlet? You can have your new one extend the current one. Your new servlet would have a service method. The get and post method would inherit from the old one.