详细介绍MyServlet代码
创始人
2024-04-12 10:50:23
0

服务器:jrun4

组件:flash remoting components as2.0

软件:flash mx 2004 pro

在安装好后,打开jrun4的管理页面,进入页面之后你会看到jrun已经创建好了3个服务器,分别是admin,default和samples,我们使用的服务器为default,对与flash remoting的相关用法可参照lwanchen的flashremoting实践(三)-hello world for java:http://www.riacn.com/web/showArticle.asp?id=111

1.在C:\jrun4\servers\default\default-ear\default-war\WEB-INF的web.xml中加入以下的标记:

  1.    
  2. MyServlet   
  3. MyServlet   
  4. This is a servlet of H2O   
  5. MyServlet   
  6.  

2.将编译好的MyServlet.class这个servlet放在classes

  1. import javax.servlet.*;  
  2. import java.io.IOException;  
  3. import java.util.List;  
  4.  
  5. public class MyServlet implements Servlet {  
  6. private String message = null;  
  7.  
  8. public void init(ServletConfig config) throws ServletException {  
  9. message = "Hello from MyServlet";  
  10. }  
  11.  
  12. public void service(ServletRequest request, ServletResponse response)  
  13. throws ServletException, IOException {  
  14. request.setAttribute("FLASH.RESULT", message);  
  15. }  
  16.  
  17. public String getServletInfo() {  
  18. return "A test servlet.";  
  19. }  
  20.  
  21. public ServletConfig getServletConfig() {  
  22. return null;  
  23. }  
  24.  
  25. public void destroy() {  
  26. message = null;  
  27. }  

3.在flash mx 2004 pro中的调用方法为:

  1. import mx.remoting.NetServices;  
  2. import mx.remoting.Connection;  
  3. NetServices.setDefaultGatewayUrl(http://localhost:8100/flashservices/gateway)  
  4. gatewayConnnection = NetServices.createGatewayConnection();  
  5. flashtestService = gatewayConnnection.getService("",this); 
  6. flashtestService.MyServlet();  
  7. function MyServlet_Result(result){  
  8. usersresult; trace(users);  

ok! MyServlet就是这么简单,但可花费了我不少的心血呀,希望大家珍惜,也祝大家能一次搞定!

【编辑推荐】

  1. 监听Servlet容器的方法
  2. Servlet和JavaServer Page使用介绍
  3. Http Servlet Request对象介绍
  4. Servlet API的强筋实力
  5. ServletContext的作用是什么

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...
2012年第四季度互联网状况报... [[71653]]  北京时间4月25日消息,据国外媒体报道,全球知名的云平台公司Akamai Te...