all groups > macromedia flash flash remoting > february 2004 >
You're in the

macromedia flash flash remoting

group:

reusing servlets


reusing servlets UTD
2/23/2004 10:30:28 PM
macromedia flash flash remoting:
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.

Re: reusing servlets glpete
2/25/2004 4:23:46 PM
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.
Re: reusing servlets UTD
3/1/2004 4:34:08 PM
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.
Re: reusing servlets glpete
3/1/2004 4:45:21 PM
AddThis Social Bookmark Button