Server: Jrun4
Component: Flash Remoting Components as2.0
Software: Flash MX Pro
After installation, open the JRUN4 Management page, you will see JRun has created 3 servers, respectively, Admin,default and samples, we use the server for default, VS Flash The related usage of remoting can refer to the flashremoting practice of Lwanchen (iii)-hello world for java:http://www.riacn.com/web/showarticle.asp?id=111
1. Add the following tag to the C:\jrun4\servers\default\default-ear\default-war\WEB-INF Web.xml:
<servlet> <servlet-name>MyServlet</servlet-name> <display-name>MyServlet</display-name> <description>This is a servlet of H2O</description> <servlet-class>MyServlet</servlet-class> </servlet>
2. Put the compiled Myservlet.class this servlet in classes.
Myservlet.java for
import javax.servlet.*;
import java.io.IOException;
import java.util.List;
public class MyServlet implements Servlet {
private String message = null;
public void init(ServletConfig config) throws ServletException {
message = "Hello from MyServlet";
}
public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
request.setAttribute("FLASH.RESULT", message);
}
public String getServletInfo() {
return "A test servlet.";
}
public ServletConfig getServletConfig() {
return null;
}
public void destroy() {
message = null;
}
}
3. The calling method in Flash MX Pro is:
import mx.remoting.NetServices;
import mx.remoting.Connection;
NetServices.setDefaultGatewayUrl("http://localhost:8100/flashservices/gateway";);
gatewayConnnection = NetServices.createGatewayConnection();
flashtestService = gatewayConnnection.getService("",this); flashtestService.MyServlet();
function MyServlet_Result(result){
users= result; trace(users);
}
Ok! It is so simple, but it can cost me a lot of painstaking efforts ah, I hope you cherish, I wish you all can be done!