Java Flash Remoting Call servlet

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.